File tree Expand file tree Collapse file tree 2 files changed +3
-6
lines changed Expand file tree Collapse file tree 2 files changed +3
-6
lines changed Original file line number Diff line number Diff line change @@ -267,13 +267,12 @@ def _check_requirement(require: str) -> bool:
267
267
True if the installed version of the dependency matches
268
268
the specified version, False otherwise.
269
269
"""
270
- import importlib .metadata as importlib_metadata
271
-
270
+ import importlib .metadata
272
271
import packaging .requirements
273
272
274
273
req = packaging .requirements .Requirement (require )
275
274
return req .specifier .contains (
276
- importlib_metadata .version (req .name ),
275
+ importlib . metadata .version (req .name ),
277
276
prereleases = True ,
278
277
)
279
278
Original file line number Diff line number Diff line change @@ -160,10 +160,8 @@ def test_stub_loading_errors(tmp_path):
160
160
161
161
162
162
def test_require_kwarg ():
163
- have_importlib_metadata = importlib .util .find_spec ("importlib.metadata" ) is not None
164
- dot = "." if have_importlib_metadata else "_"
165
163
# Test with a module that definitely exists, behavior hinges on requirement
166
- with mock .patch (f"importlib{ dot } metadata.version" ) as version :
164
+ with mock .patch (f"importlib. metadata.version" ) as version :
167
165
version .return_value = "1.0.0"
168
166
math = lazy .load ("math" , require = "somepkg >= 2.0" )
169
167
assert isinstance (math , lazy .DelayedImportErrorModule )
You can’t perform that action at this time.
0 commit comments