Skip to content

Commit b4efd3c

Browse files
authored
Fix type error on SourceFileLoader.load_module (#763)
1 parent 5426ed9 commit b4efd3c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

pynamodb/_compat.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,20 @@
66
else:
77
from inspect import getfullargspec
88

9+
910
def load_module(name, path):
1011
"""Load module using the Python version compatible function."""
1112
if sys.version_info >= (3, 3):
1213
from importlib.machinery import SourceFileLoader
13-
return SourceFileLoader(name, path).load_module()
14-
else:
14+
15+
# Typeshed is incorrect in requiring a string arg to `load_module`,
16+
# as this works with no args or a None arg.
17+
# Even `load_module` is now deprecated, so we should update to just
18+
# using the following approach in >= python 3.5:
19+
# https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
20+
loader = SourceFileLoader(name, path)
21+
return loader.load_module() # type: ignore
22+
else:
1523
from imp import load_source
1624
return load_source(name, path)
1725

0 commit comments

Comments
 (0)