Skip to content

Commit

Permalink
Safer check in _get_metadata_version
Browse files Browse the repository at this point in the history
  • Loading branch information
SmileyChris committed May 21, 2024
1 parent 2af8e80 commit 6b85972
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/towncrier/_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def _get_package(package_dir: str, package: str) -> ModuleType:
def _get_metadata_version(package: str) -> str | None:
distributions = packages_distributions()
distribution_names = distributions.get(package)
if not len(distribution_names) == 1:
# We can't determine the version if there are multiple distributions.
if not distribution_names or not len(distribution_names) == 1:
# We can only determine the version if there is exactly one matching distribution.
return None
try:
return metadata_version(distribution_names[0])
Expand Down

0 comments on commit 6b85972

Please sign in to comment.