From f104fa829f34745843629b5720e9bd86c6652cca Mon Sep 17 00:00:00 2001 From: Daniel Eades Date: Wed, 15 Sep 2021 20:06:01 +0100 Subject: [PATCH] set up mypy hook for incremental adoption --- .pre-commit-config.yaml | 15 +++++++++++++++ mypy.ini | 29 +++++++++++++++++++++++++++++ poetry/__init__.py | 3 ++- poetry/core/utils/helpers.py | 2 ++ 4 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 mypy.ini diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a2fffbc2d..e1b30c931 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,6 +16,21 @@ repos: | ^poetry/core/_vendor ) + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v0.910 + hooks: + - id: mypy + additional_dependencies: + - types-requests + files: | + (?x)( + ^poetry + ) + exclude: | + (?x)( + ^poetry/core/_vendor + ) + - repo: https://github.com/timothycrosley/isort rev: 5.8.0 hooks: diff --git a/mypy.ini b/mypy.ini new file mode 100644 index 000000000..01ebf5f9e --- /dev/null +++ b/mypy.ini @@ -0,0 +1,29 @@ +[mypy] +follow_imports = silent + +[mypy-poetry.core.factory.*] +ignore_errors = True + +[mypy-poetry.core.masonry.*] +ignore_errors = True + +[mypy-poetry.core.packages.*] +ignore_errors = True + +[mypy-poetry.core.poetry.*] +ignore_errors = True + +[mypy-poetry.core.pyproject.*] +ignore_errors = True + +[mypy-poetry.core.semver.*] +ignore_errors = True + +[mypy-poetry.core.spdx.*] +ignore_errors = True + +[mypy-poetry.core.vcs.*] +ignore_errors = True + +[mypy-poetry.core.version.*] +ignore_errors = True diff --git a/poetry/__init__.py b/poetry/__init__.py index 26cfe4052..0bd1cd515 100644 --- a/poetry/__init__.py +++ b/poetry/__init__.py @@ -1,4 +1,5 @@ from pkgutil import extend_path +from typing import List -__path__ = extend_path(__path__, __name__) +__path__: List[str] = extend_path(__path__, __name__) diff --git a/poetry/core/utils/helpers.py b/poetry/core/utils/helpers.py index 9eb47e6fd..0be8a2429 100644 --- a/poetry/core/utils/helpers.py +++ b/poetry/core/utils/helpers.py @@ -10,6 +10,7 @@ from typing import Iterator from typing import List from typing import Union +from typing import no_type_check from poetry.core.version.pep440 import PEP440Version @@ -42,6 +43,7 @@ def temporary_directory(*args: Any, **kwargs: Any) -> Iterator[str]: safe_rmtree(name) +@no_type_check def parse_requires(requires: str) -> List[str]: lines = requires.split("\n")