Skip to content

Commit

Permalink
importlib-metadata type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby authored and radoering committed May 15, 2023
1 parent 3033e2c commit ac94971
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
4 changes: 1 addition & 3 deletions src/poetry/repositories/installed_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,7 @@ def load(cls, env: Env, with_dependencies: bool = False) -> InstalledRepository:
continue

for distribution in sorted(
metadata.distributions( # type: ignore[no-untyped-call]
path=[entry],
),
metadata.distributions(path=[entry]),
key=lambda d: str(d._path), # type: ignore[attr-defined]
):
path = Path(str(distribution._path)) # type: ignore[attr-defined]
Expand Down
18 changes: 5 additions & 13 deletions src/poetry/utils/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,7 @@ def distributions(
)
)

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

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

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

def find_distribution_direct_url_json_files(
self, distribution_name: str, writable_only: bool = False
Expand All @@ -344,9 +337,8 @@ def remove_distribution_files(self, distribution_name: str) -> list[Path]:
):
files = [] if distribution.files is None else distribution.files
for file in files:
path = Path(
distribution.locate_file(file), # type: ignore[no-untyped-call]
)
path = Path(distribution.locate_file(file))

# We can't use unlink(missing_ok=True) because it's not always available
if path.exists():
path.unlink()
Expand Down

0 comments on commit ac94971

Please sign in to comment.