-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Paramspec, protocol and classmethod #13911
Labels
Comments
So that others don't have to click through, here's the snippet: from typing import TypeVar, Protocol, Type, Callable
from typing_extensions import ParamSpec
ReturnT = TypeVar("ReturnT", covariant=True)
P = ParamSpec("P")
class AsyncP(Protocol[P]):
def __init__(self, *args: P.args, **kwargs: P.kwargs) -> None:
...
class Async:
@classmethod
def async_func(cls: Type[AsyncP[P]]) -> Callable[P, int]:
...
class Add(Async):
def __init__(self, x: int, y: int) -> None:
self.x = x
self.y = y
reveal_type(Add.async_func()) And here's a link to mypy playground: https://mypy-play.net/?mypy=latest&python=3.11&gist=34604ea95d10df9b6bcf2de46e8383a2 |
ilevkivskyi
added a commit
that referenced
this issue
Aug 19, 2023
Fixes #14968 Fixes #13911 The fix is simple, as I predicted on Discord, we simply should use `get_all_type_vars()` instead of `get_type_vars()` (that specifically returns only `TypeVarType`). I also use this opportunity to tidy-up code in `bind_self()`, it should be now more readable, and much faster (especially when compiled with mypyc). cc @A5rocks --------- Co-authored-by: Alex Waygood <[email protected]>
@mehdigmira is the project you were running into this on open source? |
No the project is not open source |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Report
Mypy doesn't infer the right type in the following example.
To Reproduce
https://gist.github.com/94a0c6c7b64ea26e03b9a44ae460c6cb
Expected Behavior
mypy infers
Type of "Add.async_func()" is "(x: int, y: int) -> int"
as pyright doesActual Behavior
mypy infers
Revealed type is "def (*<nothing>, **<nothing>) -> builtins.int"
Your Environment
mypy.ini
(and other config files): noneThe text was updated successfully, but these errors were encountered: