From 3b65c915c71c7b13344918d6fc524bc9f30394e5 Mon Sep 17 00:00:00 2001 From: Daniel Eades Date: Wed, 15 Sep 2021 18:04:13 +0100 Subject: [PATCH 1/3] set up mypy hook for incremental adoption --- .pre-commit-config.yaml | 10 ++++++++++ mypy.ini | 39 +++++++++++++++++++++++++++++++++++++++ poetry/__init__.py | 3 ++- poetry/poetry.py | 3 ++- 4 files changed, 53 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b6a282e11fc..c5fb1ffe8ec 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,6 +10,16 @@ repos: - id: flake8 additional_dependencies: [flake8-bugbear] + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v0.910 + hooks: + - id: mypy + pass_filenames: false + additional_dependencies: + - types-requests + args: + - poetry + - repo: https://github.com/timothycrosley/isort rev: 5.7.0 hooks: diff --git a/mypy.ini b/mypy.ini index 9ab0f390a88..db66abac730 100644 --- a/mypy.ini +++ b/mypy.ini @@ -6,3 +6,42 @@ strict_optional = True warn_unused_ignores = True warn_redundant_casts = True warn_unused_configs = True + +[mypy-poetry.config.*] +ignore_errors = True + +[mypy-poetry.console.*] +ignore_errors = True + +[mypy-poetry.factory.*] +ignore_errors = True + +[mypy-poetry.inspection.*] +ignore_errors = True + +[mypy-poetry.installation.*] +ignore_errors = True + +[mypy-poetry.locations.*] +ignore_errors = True + +[mypy-poetry.mixology.*] +ignore_errors = True + +[mypy-poetry.packages.*] +ignore_errors = True + +[mypy-poetry.plugins.*] +ignore_errors = True + +[mypy-poetry.publishing.*] +ignore_errors = True + +[mypy-poetry.puzzle.*] +ignore_errors = True + +[mypy-poetry.repositories.*] +ignore_errors = True + +[mypy-poetry.utils.*] +ignore_errors = True diff --git a/poetry/__init__.py b/poetry/__init__.py index 26cfe4052b1..0bd1cd515c0 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/poetry.py b/poetry/poetry.py index 95814330e4a..8365bffec79 100644 --- a/poetry/poetry.py +++ b/poetry/poetry.py @@ -1,6 +1,7 @@ from pathlib import Path from typing import TYPE_CHECKING from typing import List +from typing import Optional from poetry.__version__ import __version__ from poetry.config.source import Source @@ -35,7 +36,7 @@ def __init__( self._locker = locker self._config = config self._pool = Pool() - self._plugin_manager = None + self._plugin_manager: Optional[PluginManager] = None @property def locker(self) -> "Locker": From c20212f4621fc92d8259414ea660429d99cbbccf Mon Sep 17 00:00:00 2001 From: Daniel Eades Date: Sat, 13 Nov 2021 07:08:27 +0000 Subject: [PATCH 2/3] add description to mypy whitelist --- mypy.ini | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mypy.ini b/mypy.ini index db66abac730..a6be534c118 100644 --- a/mypy.ini +++ b/mypy.ini @@ -7,6 +7,12 @@ warn_unused_ignores = True warn_redundant_casts = True warn_unused_configs = True +# The following whitelist is used to allow for incremental adoption +# of Mypy. Modules should be removed from this whitelist as and when +# their respective type errors have been addressed. No new modules +# should be added to this whitelist. +# see https://github.com/python-poetry/poetry-core/pull/199. + [mypy-poetry.config.*] ignore_errors = True @@ -45,3 +51,5 @@ ignore_errors = True [mypy-poetry.utils.*] ignore_errors = True + +# end of whitelist From 160806e9f94f001de53dffe6e7158409558cb510 Mon Sep 17 00:00:00 2001 From: Daniel Eades Date: Sat, 13 Nov 2021 07:10:48 +0000 Subject: [PATCH 3/3] fix copy-paste error --- mypy.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy.ini b/mypy.ini index a6be534c118..2bc2c873fa3 100644 --- a/mypy.ini +++ b/mypy.ini @@ -11,7 +11,7 @@ warn_unused_configs = True # of Mypy. Modules should be removed from this whitelist as and when # their respective type errors have been addressed. No new modules # should be added to this whitelist. -# see https://github.com/python-poetry/poetry-core/pull/199. +# see https://github.com/python-poetry/poetry/pull/4510. [mypy-poetry.config.*] ignore_errors = True