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
Union[List[T], T] is not recognized by mypy
Union[List[T], T]
To Reproduce
from typing import List, Union, TypeVar T = TypeVar('T') def first_or_only(x: Union[List[T], T]) -> T: pass x1: int = first_or_only(1) x2: int = first_or_only([1, 2, 3]) x3: tuple = first_or_only((1, 2, 3))
Expected Behavior
Both vs code and pycharm inference as 1 + 2a + 3.
vs code
pycharm
Actual Behavior
Mypy output for the example above makes no sense to me:
error: Argument 1 to "first_or_only" has incompatible type "List[int]"; expected "List[<nothing>]" Found 1 error in 1 file (checked 1 source file)
Your Environment
mypy.ini
The text was updated successfully, but these errors were encountered:
Relevant: #11149
Sorry, something went wrong.
Can I check this issue..i am beginner in open source contribution however I can analyse it for further clarity .please input your suggestion ..
I guess the same issue with
from typing import TypeVar StdPrimitiveType = TypeVar("StdPrimitiveType", int, float, str, bool) def foo(val: StdPrimitiveType | set[StdPrimitiveType]): pass foo({"a", "b"})
error: Argument 1 has incompatible type "Set[str]"; expected "Union[bool, Set[bool]]" [arg-type]
No branches or pull requests
Bug Report
Union[List[T], T]
is not recognized by mypyTo Reproduce
Expected Behavior
Both
vs code
andpycharm
inference as 1 + 2a + 3.Actual Behavior
Mypy output for the example above makes no sense to me:
Your Environment
mypy.ini
(and other config files): noneThe text was updated successfully, but these errors were encountered: