chore: upgrade mypy and add type guards (#16227)

This commit is contained in:
Ville Brofeldt
2021-08-14 06:31:45 +03:00
committed by GitHub
parent 9b2dffeb1d
commit d46dc9aa45
9 changed files with 29 additions and 18 deletions

View File

@@ -44,9 +44,13 @@ def import_migration_script(filepath: Path) -> ModuleType:
Import migration script as if it were a module.
"""
spec = importlib.util.spec_from_file_location(filepath.stem, filepath)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module) # type: ignore
return module
if spec:
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module) # type: ignore
return module
raise Exception(
"No module spec found in location: `{path}`".format(path=str(filepath))
)
def extract_modified_tables(module: ModuleType) -> Set[str]: