fix mypy typing errors in pytorch_lightning.__setup__.py (#13472)
Fix typing in _load_py_module function
This commit is contained in:
parent
a80354e3ae
commit
f65aa74719
|
@ -26,7 +26,9 @@ _PACKAGE_MAPPING = {"pytorch": "pytorch_lightning", "app": "lightning_app"}
|
|||
|
||||
def _load_py_module(name: str, location: str) -> ModuleType:
|
||||
spec = spec_from_file_location(name, location)
|
||||
assert spec, f"Failed to load module {name} from {location}"
|
||||
py = module_from_spec(spec)
|
||||
assert spec.loader, f"ModuleSpec.loader is None for {name} from {location}"
|
||||
spec.loader.exec_module(py)
|
||||
return py
|
||||
|
||||
|
|
|
@ -95,6 +95,5 @@ module = [
|
|||
"pytorch_lightning.utilities.data",
|
||||
"pytorch_lightning.utilities.distributed",
|
||||
"pytorch_lightning.utilities.meta",
|
||||
"pytorch_lightning.__setup__",
|
||||
]
|
||||
ignore_errors = "True"
|
||||
|
|
2
setup.py
2
setup.py
|
@ -74,7 +74,9 @@ with open(__file__, "w") as fp:
|
|||
|
||||
def _load_py_module(name: str, location: str) -> ModuleType:
|
||||
spec = spec_from_file_location(name, location)
|
||||
assert spec, f"Failed to load module {name} from {location}"
|
||||
py = module_from_spec(spec)
|
||||
assert spec.loader, f"ModuleSpec.loader is None for {name} from {location}"
|
||||
spec.loader.exec_module(py)
|
||||
return py
|
||||
|
||||
|
|
|
@ -15,7 +15,9 @@ _FREEZE_REQUIREMENTS = bool(int(os.environ.get("FREEZE_REQUIREMENTS", 0)))
|
|||
|
||||
def _load_py_module(name: str, location: str) -> ModuleType:
|
||||
spec = spec_from_file_location(name, location)
|
||||
assert spec, f"Failed to load module {name} from {location}"
|
||||
py = module_from_spec(spec)
|
||||
assert spec.loader, f"ModuleSpec.loader is None for {name} from {location}"
|
||||
spec.loader.exec_module(py)
|
||||
return py
|
||||
|
||||
|
|
|
@ -14,7 +14,9 @@ _FREEZE_REQUIREMENTS = bool(int(os.environ.get("FREEZE_REQUIREMENTS", 0)))
|
|||
|
||||
def _load_py_module(name: str, location: str) -> ModuleType:
|
||||
spec = spec_from_file_location(name, location)
|
||||
assert spec, f"Failed to load module {name} from {location}"
|
||||
py = module_from_spec(spec)
|
||||
assert spec.loader, f"ModuleSpec.loader is None for {name} from {location}"
|
||||
spec.loader.exec_module(py)
|
||||
return py
|
||||
|
||||
|
|
|
@ -15,7 +15,9 @@ _FREEZE_REQUIREMENTS = bool(int(os.environ.get("FREEZE_REQUIREMENTS", 0)))
|
|||
|
||||
def _load_py_module(name: str, location: str) -> ModuleType:
|
||||
spec = spec_from_file_location(name, location)
|
||||
assert spec, f"Failed to load module {name} from {location}"
|
||||
py = module_from_spec(spec)
|
||||
assert spec.loader, f"ModuleSpec.loader is None for {name} from {location}"
|
||||
spec.loader.exec_module(py)
|
||||
return py
|
||||
|
||||
|
|
Loading…
Reference in New Issue