-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Pylance error when using a @retry decorator on a function #5035
Comments
The stubs look correct to me and mypy accepts the code above. But I may be missing something. Maybe @erictraut can help? |
I'm not able to repro the error using Pylance or Pyright. Can you verify that your sample above produces an error for you? There is one thing I see that wrong with the stub. The |
My humble apologies. I'll have to figure out why this is happening, but clearly it's not a typeshed issue. Should I close this or leave it open in light of Eric's comment? |
@srittau, @hauntsaninja, Out of curiosity, does mypy or stubtest have a mode where they flag missing type arguments for generic classes or type aliases? If so, would it make sense to enable that in the CI tests for typeshed? This is a common mistake that I see in typeshed stubs. |
@hudcap, if you right click on |
@erictraut, it looks like my workspace is pointing to the typeshed stubs in pylance 2021.2.2, but outside the workspace it's pointing to the stubs in 2021.2.3 Thank you everyone! |
I am not sure about such an option, but we should consider running the tests through pylance well, anyway. |
Yes, mypy has |
I fixed all of these in stdlib stubs several months ago, but it tends to regress because it's not enforced. |
It looks like @srittau added Note that |
Perhaps this issue should be closed and several new issues should be opened:
Does that sound right? |
I'd love to see #3 (pyright in typeshed CI) happen; is there anything blocking that? |
@JelleZijlstra Probably just someone that implements this. :) But I have opened #5048 in the meantime. |
I think this issue can be closed. The original issue has been addressed, and pyright is now included in the typeshed CI test suite. |
Asked on SO here with no response.
There are discussions about decorators (python/mypy#1551, python/mypy#3157) that are above my head, but it seems that my use-case was solved.
I'm not sure if I'm reporting a bug or my stupidity, but...
I have a function that runs some code based on random variables. There are some assertion checks on the random variables, so I use a
@retry
decorator from the retry pip package on the function. Everything works perfectly.MWE:
However, I started using
pylance
in VS Code with type checking set to "basic" and it's throwing the following error:The stub being used is https://github.com/python/typeshed/blob/master/stubs/retry/retry/api.pyi
From my beginner's understanding, it looks right, and if I change the second line here from
to
it's happy, which doesn't make any sense to me, since
_T
should not be any "stricter" than its bound.So either there's an issue, or I'm in over my head and completely lost.
I'm new to type checking and trying to learn, so please go easy on me... :)
The text was updated successfully, but these errors were encountered: