Skip to content
Please note that GitHub no longer supports your web browser.

We recommend upgrading to the latest Google Chrome or Firefox.

Learn more
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce mypy stub for typeguard, and type-check parsl.load() #874

Merged
merged 2 commits into from Apr 24, 2019

Conversation

@benclifford
Copy link
Contributor

benclifford commented Apr 14, 2019

Introduce mypy stub for typeguard, and type-check parsl.load()

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 @typeguard.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.

@benclifford benclifford force-pushed the benc-enforce-vs-mypy branch from e1b9ce3 to 7ff792c Apr 14, 2019
@benclifford benclifford changed the title Introduce mypy stub for enforce.py, and type-check parsl.load() [don't merge yet] Introduce mypy stub for enforce.py, and type-check parsl.load() Apr 14, 2019
@benclifford

This comment has been minimized.

Copy link
Contributor Author

benclifford commented Apr 14, 2019

i'd like #875 merged, and this pr updated for that first

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.
@benclifford benclifford force-pushed the benc-enforce-vs-mypy branch 3 times, most recently from 9a20485 to ecaa0ac Apr 15, 2019
@benclifford benclifford requested a review from annawoodard Apr 15, 2019
@benclifford benclifford changed the title [don't merge yet] Introduce mypy stub for enforce.py, and type-check parsl.load() Introduce mypy stub for enforce.py, and type-check parsl.load() Apr 15, 2019
@benclifford benclifford changed the title Introduce mypy stub for enforce.py, and type-check parsl.load() Introduce mypy stub for typeguard, and type-check parsl.load() Apr 15, 2019
@benclifford benclifford merged commit e10c287 into master Apr 24, 2019
1 check passed
1 check passed
Travis CI - Pull Request Build Passed
Details
@benclifford benclifford deleted the benc-enforce-vs-mypy branch Apr 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.