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
Bug Report
To Reproduce
from typing import Any, Generic, TypeVar T = TypeVar("T") class Foo(Generic[T]): def __init__(self, value: T): self.value = value def identity(value: T) -> Foo[T]: if isinstance(value, str): return Foo(value) return Foo(value)
Expected Behavior
mypy should be able to tell that in the type-guarded block, T == str and use that to qualify the types.
T == str
Actual Behavior
mypy reports an error Argument 1 to "Foo" has incompatible type "str"; expected "T" in the type-guarded block in identity().
Argument 1 to "Foo" has incompatible type "str"; expected "T"
identity()
Your Environment
mypy.ini
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Bug Report
To Reproduce
Expected Behavior
mypy should be able to tell that in the type-guarded block,
T == str
and use that to qualify the types.Actual Behavior
mypy reports an error
Argument 1 to "Foo" has incompatible type "str"; expected "T"
in the type-guarded block inidentity()
.Your Environment
mypy.ini
(and other config files): N/AThe text was updated successfully, but these errors were encountered: