File tree Expand file tree Collapse file tree 2 files changed +3
-5
lines changed Expand file tree Collapse file tree 2 files changed +3
-5
lines changed Original file line number Diff line number Diff line change @@ -267,13 +267,13 @@ 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
270
+ import importlib .metadata
271
271
272
272
import packaging .requirements
273
273
274
274
req = packaging .requirements .Requirement (require )
275
275
return req .specifier .contains (
276
- importlib_metadata .version (req .name ),
276
+ importlib . metadata .version (req .name ),
277
277
prereleases = True ,
278
278
)
279
279
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 ("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