FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix pytype error when dynamically importing a python file. · NeoTim/python-spanner-orm@3af5eca · GitHub

Commit 3af5eca

Browse files
committed
Fix pytype error when dynamically importing a python file.
See google/pytype#319 for context on the error. Addresses google#93.
1 parent 7db9acb commit 3af5eca

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

‎spanner_orm/admin/migration_manager.py‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,9 @@ def _migration_from_file(self, filename: str) -> migration.Migration:
7272
"""Loads a single migration from the given filename in the base dir."""
7373
module_name = re.sub(r'\W', '_', filename)
7474
path = os.path.join(self.basedir, filename)
75-
spec = importlib.util.spec_from_file_location(module_name, path)
76-
module = importlib.util.module_from_spec(spec)
77-
# TODO(#93): Remove pytype disable below.
78-
spec.loader.exec_module(module) # type: ignore
75+
module = importlib.util.module_from_spec(
76+
importlib.util.spec_from_file_location(module_name, path))
77+
importlib.machinery.SourceFileLoader(module_name, path).exec_module(module)
7978
try:
8079
result = migration.Migration(module.migration_id,
8180
module.prev_migration_id,

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL