From 39f3b64509a9f0c22fbc92105a21902d5e172d72 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Mon, 14 Mar 2022 15:53:14 +0000 Subject: [PATCH] Minor mypy improvements This fixes several mypy issues reported by vscode mypy integration. --- .pre-commit-config.yaml | 2 +- docs/conf.py | 4 ++-- mypy.ini | 5 +++-- plugins/modules/fake_module.py | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3f4c2f355e..154f1c3166 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -128,7 +128,7 @@ repos: - rich>=11.0.0 - ruamel.yaml - sphinx>=4.4.0 - - types-PyYAML + - types-pyyaml>=6.0.4 - types-dataclasses - types-docutils - types-pkg_resources diff --git a/docs/conf.py b/docs/conf.py index 8a75713ac7..5f2498a729 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -18,7 +18,7 @@ import os import sys from pathlib import Path -from typing import List +from typing import List, Optional import pkg_resources @@ -96,7 +96,7 @@ apidoc_module_first = False apidoc_output_dir = "pkg" apidoc_separate_modules = True -apidoc_toc_file = None +apidoc_toc_file: Optional[str] = None # General substitutions. project = "Ansible Lint Documentation" diff --git a/mypy.ini b/mypy.ini index 655bafcf10..cb756fc9d8 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,5 +1,5 @@ [mypy] -python_version = 3.6 +python_version = 3.8 color_output = True error_summary = True disallow_untyped_calls = True @@ -9,7 +9,8 @@ disallow_any_generics = True ; warn_redundant_casts = True ; warn_return_any = True ; warn_unused_configs = True -exclude = test/local-content +# site-packages is here to help vscode mypy integration getting confused +exclude = (build|test/local-content|site-packages) # 3rd party ignores [mypy-ansible] diff --git a/plugins/modules/fake_module.py b/plugins/modules/fake_module.py index bff2f023ed..29e8dc0adb 100644 --- a/plugins/modules/fake_module.py +++ b/plugins/modules/fake_module.py @@ -5,7 +5,7 @@ from ansible.module_utils.basic import AnsibleModule -def main(): +def main() -> None: """Return the module instance.""" return AnsibleModule( argument_spec=dict(