Skip to content

Commit

Permalink
chore: ignore some type errors related to importlib_metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
mkniewallner committed Oct 1, 2022
1 parent 62ea441 commit d1b4f96
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 3 additions & 1 deletion deptry/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,6 @@ def deptry(


def display_deptry_version() -> None:
logging.info(f'deptry {metadata.version("deptry")}')
logging.info(
f'deptry {metadata.version("deptry")}'
) # mypy: warn-unused-ignores=false # type: ignore[no-untyped-call]
10 changes: 7 additions & 3 deletions deptry/dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __str__(self) -> str:

def find_metadata(self, name: str) -> bool:
try:
metadata.distribution(name)
metadata.distribution(name) # mypy: warn-unused-ignores=false # type: ignore[no-untyped-call]
return True
except PackageNotFoundError:
logging.warning(
Expand Down Expand Up @@ -80,7 +80,9 @@ def _get_top_level_module_names_from_top_level_txt(self) -> List[str]:
This function extracts these names, if a top-level.txt file exists.
"""
metadata_top_levels = metadata.distribution(self.name).read_text("top_level.txt")
metadata_top_levels = metadata.distribution(self.name).read_text(
"top_level.txt"
) # mypy: warn-unused-ignores=false # type: ignore[no-untyped-call]
if metadata_top_levels:
return [x for x in metadata_top_levels.split("\n") if len(x) > 0]
else:
Expand All @@ -101,7 +103,9 @@ def _get_top_level_module_names_from_record_file(self) -> List[str]:
"""
top_levels = []
try:
metadata_records = metadata.distribution(self.name).read_text("RECORD")
metadata_records = metadata.distribution(self.name).read_text(
"RECORD"
) # mypy: warn-unused-ignores=false # type: ignore[no-untyped-call]

if not metadata_records:
return []
Expand Down
5 changes: 4 additions & 1 deletion deptry/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ def _get_package_name_from_metadata(self) -> Optional[str]:
Most packages simply have a field called "Name" in their metadata. This method extracts that field.
"""
try:
return metadata.metadata(self.name)["Name"]
name: str = metadata.metadata(self.name)[
"Name"
] # mypy: warn-unused-ignores=false # type: ignore[no-untyped-call]
return name
except PackageNotFoundError:
return None

Expand Down

0 comments on commit d1b4f96

Please sign in to comment.