File tree 1 file changed +20
-12
lines changed
1 file changed +20
-12
lines changed Original file line number Diff line number Diff line change @@ -151,21 +151,29 @@ def safer_best_effort_version(value: str) -> str:
151
151
return filename_component (best_effort_version (value ))
152
152
153
153
154
+ def _missing_canonicalize_license_expression (expression : str ) -> str :
155
+ """
156
+ Defer import error to affect only users that actually use it
157
+ https://github.com/pypa/setuptools/issues/4894
158
+ >>> _missing_canonicalize_license_expression("a OR b")
159
+ Traceback (most recent call last):
160
+ ...
161
+ ImportError: ...Cannot import `packaging.licenses`...
162
+ """
163
+ raise ImportError (
164
+ "Cannot import `packaging.licenses`."
165
+ """
166
+ Setuptools>=77.0.0 requires "packaging>=24.2" to work properly.
167
+ Please make sure you have a suitable version installed.
168
+ """
169
+ )
170
+
171
+
154
172
try :
155
173
from packaging .licenses import (
156
174
canonicalize_license_expression as _canonicalize_license_expression ,
157
175
)
158
- except ImportError :
176
+ except ImportError : # pragma: nocover
159
177
if not TYPE_CHECKING :
160
178
# 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
- )
179
+ _canonicalize_license_expression = _missing_canonicalize_license_expression
You can’t perform that action at this time.
0 commit comments