-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add type hints for @typechecked #96
Conversation
This breaks too many tests. Please try if reverting the lines I commented fixes this. One would think it cannot be caused by anything else as the asserts etc are not invasive. But then there was the recent incident with the blank line breaking a test... |
Yeah, you're right, sorry for the noise. I think I'm going to drop all the little fixes from this PR since any remaining improvements are pretty minor by themselves. Besides that, I'm also updating the pyi file to be more complete and include types for |
Would it work to make this a Or does the static typechecker strictly require the |
Yeah, that's fair, I agree that's probably the way to go. Let me look into that and update you when it's ready for another look. |
I have second thoughts on the At first glance I thought this could solve the issue with annotating functions from
but anyway, that's beyond this PR. Just explaining my reasoning that led to the idea with |
I suppose there is a way to let mypy validate whether the |
Looks like no per python/mypy#5028. What I'd done is used |
Isn't there a (simple) way to get mypy in case of an invalid stubfile produce these little "no such attribute" errors you mentioned?
Maybe we should consider to add such kind of thing to pytypes. It's intended to host useful utilities for typing, actually. |
The "no such attribute" errors I mentioned were from calling code referencing pytypes code that wasn't in the pyi. The unsolved problem is comparing the .py to the .pyi and noticing discrepancies like missing functions, wrong number of params, etc.
Good idea! I filed issue #100 for this. I hadn't seen anything about |
96bf2cb
to
1c67978
Compare
It's just internal and hardly documented. It locates stubfiles and attaches the types therein to the members of the original module. It is the motor of |
4805cdd
to
fb132eb
Compare
Sorry to bother again. I already thought it could be merged, then the two cleanup comments occurred to me... |
K, should be 100% good to go now. Take a look. |
Thanks for working this through! |
Adds a py.typed marker file to indicate pytypes has type hints (see PEP 561), and adds type hints for
@typechecked
. These type hints are added in a separate pyi file to help with compatibility for python 3.3 & 3.4, since inline type annotations are a syntax error for those versions.The fixes in typechecker.py were for issues flagged by the typechecker and shouldn't change the behavior of the code at all. They may not be strictly needed since type hint resolution order is supposed to check *.pyi files before their associated *.py files.EDIT: Dropped the type checker fixes. They were more trouble than I expected and probably not needed.
Fixes #74.