Permalink
Please
sign in to comment.
Browse files
Introduce mypy stub for typeguard, and type-check parsl.load() (#874)
This allows mypy to understand the type signatures of functions decorated with @typeguard.typechecked, allowing the type signatures on such functions to be used by both enforce and mypy. Prior to this commit, adding @TypeChecked removed the ability of mypy to type-check calls to decorated functions, as it did not understand that the type of such a decorated function is the same as the original function. The added stub makes this declaration. The test-suite mypy calls are modified to use that stub file. The immediate motivation for this is to keep mypy passing when adding a type annotation for parsl.load; that type annotation is also added in this commit. This commit fixes some of problem described in the commit message for d7d9a25 about breaking mypy type checking for end user Configs in some places, but by no means all of it. However there is a mypy bug, python/mypy#5398, where decorated __init__ methods are not properly type-checked by mypy, which means that mypy typechecking is still missing on any decorated __init__ methods - which unfortunately is most of the user-facing type checked code. At time of writing, there are PRs open to fix this in mypy, so there is hope; and that does not impede this PR being merged.
- Loading branch information
Showing
with
15 additions
and 5 deletions.
- +1 −1 .travis.yml
- +10 −0 mypy-stubs/typeguard.pyi
- +0 −3 mypy.ini
- +4 −1 parsl/dataflow/dflow.py
@@ -0,0 +1,10 @@ | ||
|
||
# this type for runtime_validation is based on the | ||
# "Decorators that do not change the signature of the function" section of | ||
# https://github.com/python/mypy/issues/3157 | ||
|
||
from typing import TypeVar, List | ||
|
||
Func = TypeVar('Func') | ||
|
||
def typechecked(f: Func) -> Func: ... |
0 comments on commit
e10c287