Skip to content

Commit

Permalink
Restore single-expression logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Aug 20, 2024
1 parent debb516 commit e99c105
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions importlib_metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1088,13 +1088,14 @@ def _get_toplevel_name(name: PackagePath) -> str:
>>> _get_toplevel_name(PackagePath('foo.dist-info'))
'foo.dist-info'
"""
if n := _topmost(name):
return n

# We're deffering import of inspect to speed up overall import time
import inspect

return inspect.getmodulename(name) or str(name)
return _topmost(name) or (
# python/typeshed#10328
inspect.getmodulename(name) # type: ignore
or str(name)
)


def _top_level_inferred(dist):
Expand Down

0 comments on commit e99c105

Please sign in to comment.