Simplify spec_matches_module_path

This commit is contained in:
Bruno Oliveira 2024-04-06 12:11:00 -03:00
parent fddb7db189
commit 24c7d2c2a0
1 changed files with 4 additions and 4 deletions

View File

@ -650,10 +650,10 @@ def spec_matches_module_path(
module_spec: Optional[ModuleSpec], module_path: Path
) -> bool:
"""Return true if the given ModuleSpec can be used to import the given module path."""
if module_spec is not None and module_spec.origin is not None:
if Path(module_spec.origin) == module_path:
return True
return False
if module_spec is None or module_spec.origin is None:
return False
return Path(module_spec.origin) == module_path
# Implement a special _is_same function on Windows which returns True if the two filenames