Skip to content

Commit 05cb079

Browse files
committed
Add comments clarifying implementation choices
1 parent 0bda2fe commit 05cb079

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

importlib_metadata/_py39compat.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"""
44
from typing import TYPE_CHECKING, Any, Optional, Tuple
55

6-
7-
if TYPE_CHECKING:
6+
if TYPE_CHECKING: # -> prevent circular imports on runtime.
87
from . import Distribution, EntryPoint
98
else:
109
Distribution = EntryPoint = Any
@@ -17,7 +16,7 @@ def normalized_name(dist: Distribution) -> Optional[str]:
1716
try:
1817
return dist._normalized_name
1918
except AttributeError:
20-
from . import Prepared
19+
from . import Prepared # -> delay to prevent circular imports.
2120

2221
return Prepared.normalize(getattr(dist, "name", None) or dist.metadata['Name'])
2322

@@ -41,7 +40,7 @@ def ep_matches(ep: EntryPoint, **params) -> Tuple[EntryPoint, bool]:
4140
try:
4241
return ep, ep.matches(**params)
4342
except AttributeError:
44-
from . import EntryPoint
43+
from . import EntryPoint # -> delay to prevent circular imports.
4544

4645
# Reconstruct the EntryPoint object to make sure it is compatible.
4746
_ep = EntryPoint(ep.name, ep.value, ep.group)

0 commit comments

Comments
 (0)