We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
__init__
Bug Report
A typevar (not concrete) leaks out of a __init__ call in some overloaded contexts.
To Reproduce
from __future__ import annotations from typing import Generic, TypeVar, overload, Callable T = TypeVar("T") U1 = TypeVar("U1") U2 = TypeVar("U2") class X(Generic[T]): @overload def __init__(self: X[U1], *, x: U1) -> None: ... @overload def __init__(self: X[U2], *, y: U2) -> None: ... def __init__(self: X[U1 | U2], *, x: U1 | None = None, y: U2 | None = None, z: Callable[[U1], None] | Callable[[U2], None] | None = None): self.z = z reveal_type(X(x=5).z) # N: Revealed type is "Union[def (U1`-1), def (U2`-2), None]"
here's a minimum reproduction, the above is only relevant as "why would you want this?":
from __future__ import annotations from typing import Generic, TypeVar, Callable T = TypeVar("T") U = TypeVar("U") class X(Generic[T]): def __init__(self: X[U], x: U): self.x = x reveal_type(X(x=5).x)
Expected Behavior
# N: Revealed type is Union[def (int), def (int), None] or # N: Revealed type is Union[def (int), None].
# N: Revealed type is Union[def (int), def (int), None]
# N: Revealed type is Union[def (int), None]
Actual Behavior
# N: Revealed type is "Union[def (U1`-1), def (U2`-2), None]"
Your Environment
Tested in mypy-play.
mypy.ini
The text was updated successfully, but these errors were encountered:
RaisesGroup
No branches or pull requests
Bug Report
A typevar (not concrete) leaks out of a
__init__
call in some overloaded contexts.To Reproduce
here's a minimum reproduction, the above is only relevant as "why would you want this?":
Expected Behavior
# N: Revealed type is Union[def (int), def (int), None]
or# N: Revealed type is Union[def (int), None]
.Actual Behavior
Your Environment
Tested in mypy-play.
mypy.ini
(and other config files): noneThe text was updated successfully, but these errors were encountered: