-
-
Notifications
You must be signed in to change notification settings - Fork 3k
t.Optional[t.Union[...]]
leads to incorrect behaviour
#19204
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
Comments
I strongly suspect this is because mypy doesn't see types for Are you sure the |
Hey, thanks for the reply.
I am not sure whether this affects the issue I am seeing. The issue is that I am sure the |
Try installing |
Thanks @hauntsaninja, |
After you assign |
Uh oh!
There was an error while loading. Please reload this page.
Bug Report
When using
t.Optional
witht.Union
,mypy
checks fail with conditional processing of different types. However, removingt.Optional
from the code below leads to a successful check.To Reproduce
Expected Behavior
I would have expected this code to pass
mypy
type-checking because annp.ndarray
type is separately cast intopd.Series
orpd.DataFrame
.Actual Behavior
Get the following error:
Your Environment
mypy==1.16.0
pandas==2.2.3
numpy==2.2.6
mypy.ini
(and other config files): -Edits: Removed redundant comments.
The text was updated successfully, but these errors were encountered: