Skip to content

Commit

Permalink
set up mypy hook for incremental adoption
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleades committed Nov 14, 2021
1 parent 0362ffb commit d7423df
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 7 deletions.
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/pycqa/isort
rev: 5.9.3
hooks:
Expand Down
37 changes: 37 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[mypy]
follow_imports = silent

# 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.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

# end of whitelist
3 changes: 2 additions & 1 deletion poetry/__init__.py
Original file line number Diff line number Diff line change
@@ -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__)
9 changes: 3 additions & 6 deletions poetry/core/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,18 @@
import stat
import tempfile

from collections.abc import Mapping
from contextlib import contextmanager
from pathlib import Path
from typing import Any
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


try:
from collections.abc import Mapping
except ImportError:
from collections import Mapping


_canonicalize_regex = re.compile(r"[-_]+")


Expand All @@ -42,6 +38,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")

Expand Down

0 comments on commit d7423df

Please sign in to comment.