Skip to content

Commit 53fc322

Browse files
committed
Silence typechecking in complicated statement
1 parent 64612bf commit 53fc322

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

setuptools/_normalization.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""
55

66
import re
7+
from typing import TYPE_CHECKING
78

89
import packaging
910

@@ -155,14 +156,16 @@ def safer_best_effort_version(value: str) -> str:
155156
canonicalize_license_expression as _canonicalize_license_expression,
156157
)
157158
except ImportError:
158-
159-
def _canonicalize_license_expression(expression: str) -> str: # type: ignore[misc] # pyright: ignore[reportAssignmentType]
160-
# Defer import error to affect only users that actually use it
161-
# https://github.com/pypa/setuptools/issues/4894
162-
raise ImportError(
163-
"Cannot import `packaging.licenses`."
164-
"""
165-
Setuptools>=77.0.0 requires "packaging>=24.2" to work properly.
166-
Please make sure you have a suitable version installed.
167-
"""
168-
)
159+
if not TYPE_CHECKING:
160+
# XXX: pyright is still upset even with # pyright: ignore[reportAssignmentType]
161+
162+
def _canonicalize_license_expression(expression: str) -> str:
163+
# Defer import error to affect only users that actually use it
164+
# https://github.com/pypa/setuptools/issues/4894
165+
raise ImportError(
166+
"Cannot import `packaging.licenses`."
167+
"""
168+
Setuptools>=77.0.0 requires "packaging>=24.2" to work properly.
169+
Please make sure you have a suitable version installed.
170+
"""
171+
)

0 commit comments

Comments
 (0)