Skip to content

Commit

Permalink
typechecking for the pipelines
Browse files Browse the repository at this point in the history
coping with with as-yet-untyped poetry.core, and different python
versions
  • Loading branch information
dimbleby authored and neersighted committed May 23, 2022
1 parent cd4247f commit eb38a4e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ enable_error_code = [
[[tool.mypy.overrides]]
module = [
'poetry.installation.executor',
'poetry.repositories.installed_repository',
'poetry.mixology.version_solver',
'poetry.repositories.installed_repository',
'poetry.utils.env',
]
warn_unused_ignores = false

Expand Down
21 changes: 16 additions & 5 deletions src/poetry/utils/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,10 @@ def distributions(
)
)

yield from metadata.PathDistribution.discover(name=name, path=path)
yield from metadata.PathDistribution.discover( # type: ignore[no-untyped-call]
name=name,
path=path,
)

def find_distribution(
self, name: str, writable_only: bool = False
Expand All @@ -326,7 +329,9 @@ def find_distribution_files_with_suffix(
assert distribution.files is not None
for file in distribution.files:
if file.name.endswith(suffix):
yield Path(distribution.locate_file(file))
yield Path(
distribution.locate_file(file), # type: ignore[no-untyped-call]
)

def find_distribution_files_with_name(
self, distribution_name: str, name: str, writable_only: bool = False
Expand All @@ -337,7 +342,9 @@ def find_distribution_files_with_name(
assert distribution.files is not None
for file in distribution.files:
if file.name == name:
yield Path(distribution.locate_file(file))
yield Path(
distribution.locate_file(file), # type: ignore[no-untyped-call]
)

def find_distribution_nspkg_pth_files(
self, distribution_name: str, writable_only: bool = False
Expand Down Expand Up @@ -365,7 +372,9 @@ def remove_distribution_files(self, distribution_name: str) -> list[Path]:
):
assert distribution.files is not None
for file in distribution.files:
path = Path(distribution.locate_file(file))
path = Path(
distribution.locate_file(file), # type: ignore[no-untyped-call]
)
# We can't use unlink(missing_ok=True) because it's not always available
if path.exists():
path.unlink()
Expand Down Expand Up @@ -883,6 +892,7 @@ def create_venv(

if not name:
name = self._poetry.package.name
assert name is not None

python_patch = ".".join([str(v) for v in sys.version_info[:3]])
python_minor = ".".join([str(v) for v in sys.version_info[:2]])
Expand Down Expand Up @@ -1395,7 +1405,8 @@ def get_paths(self) -> dict[str, str]:
raise NotImplementedError()

def is_valid_for_marker(self, marker: BaseMarker) -> bool:
return marker.validate(self.marker_env)
valid: bool = marker.validate(self.marker_env)
return valid

def is_sane(self) -> bool:
"""
Expand Down

0 comments on commit eb38a4e

Please sign in to comment.