diff options
author | Olly Cope <olly@ollycope.com> | 2022-10-03 09:09:42 +0000 |
---|---|---|
committer | Olly Cope <olly@ollycope.com> | 2022-10-03 09:09:42 +0000 |
commit | 60ba14d1c572f1e1856795f7d16bbec8f115dea1 (patch) | |
tree | f29a91a5d3687b9ef672133c70c5c90b317ca43c | |
parent | ad0e39a235fcdd19e295f4d5a9410b189fe752a9 (diff) | |
download | yoyo-60ba14d1c572f1e1856795f7d16bbec8f115dea1.tar.gz |
Fix linter errors
-rwxr-xr-x | yoyo/migrations.py | 7 | ||||
-rw-r--r-- | yoyo/tests/test_topologicalsort.py | 3 |
2 files changed, 6 insertions, 4 deletions
diff --git a/yoyo/migrations.py b/yoyo/migrations.py index 2c067ee..b4d1a7d 100755 --- a/yoyo/migrations.py +++ b/yoyo/migrations.py @@ -176,6 +176,7 @@ class Migration(object): self.module = types.ModuleType(self.path) else: spec = importlib.util.spec_from_file_location(self.path, self.path) + assert spec is not None self.module = importlib.util.module_from_spec(spec) self.module.step = collector.add_step # type: ignore @@ -210,7 +211,9 @@ class Migration(object): else: try: - if spec.loader is None: + if spec and spec.loader: + spec.loader.exec_module(self.module) + else: logger.exception( "Could not import migration from %r: " "ModuleSpec has no loader attached", @@ -218,8 +221,6 @@ class Migration(object): ) raise exceptions.BadMigration(self.path) - spec.loader.exec_module(self.module) # type: ignore - except Exception as e: logger.exception("Could not import migration from %r: %r", self.path, e) raise exceptions.BadMigration(self.path, e) diff --git a/yoyo/tests/test_topologicalsort.py b/yoyo/tests/test_topologicalsort.py index be308d2..6ff7afb 100644 --- a/yoyo/tests/test_topologicalsort.py +++ b/yoyo/tests/test_topologicalsort.py @@ -1,4 +1,5 @@ import itertools +import typing as t import pytest @@ -7,7 +8,7 @@ from yoyo import topologicalsort class TestTopologicalSort(object): def check(self, nodes, edges, expected): - deps = {} + deps: t.Dict[str, t.Set[str]] = {} edges = edges.split() if edges else [] for a, b in edges: deps.setdefault(a, set()).add(b) |