Skip to content
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

TYP: Non-overlapping identity checks with pd.NaT #44213

Closed
twoertwein opened this issue Oct 28, 2021 · 3 comments
Closed

TYP: Non-overlapping identity checks with pd.NaT #44213

twoertwein opened this issue Oct 28, 2021 · 3 comments
Labels
Needs Triage Issue that has not been reviewed by a pandas team member Typing type annotations, mypy/pyright type checking

Comments

@twoertwein
Copy link
Member

twoertwein commented Oct 28, 2021

Either wrong type annotations in pandas/core/ops/mask_ops.py or there are a few branches that will never get hit (bool | np.ndarray can never be NAType).

Found in #43744

pandas/core/ops/mask_ops.py:49: error: Non-overlapping identity check (left operand type: "Union[bool, ndarray[Any, Any]]", right operand type: "NAType") [comparison-overlap]
pandas/core/ops/mask_ops.py:66: error: Non-overlapping identity check (left operand type: "Union[bool, ndarray[Any, Any]]", right operand type: "NAType") [comparison-overlap]
pandas/core/ops/mask_ops.py:106: error: Non-overlapping identity check (left operand type: "Union[bool, ndarray[Any, Any]]", right operand type: "NAType") [comparison-overlap]
pandas/core/ops/mask_ops.py:114: error: Non-overlapping identity check (left operand type: "Union[bool, ndarray[Any, Any]]", right operand type: "NAType") [comparison-overlap]

edit: happens in a few more places as well

pandas/core/arrays/timedeltas.py:537: error: Non-overlapping identity check (left operand type: "Timedelta", right operand type: "NaTType") [comparison-overlap]
pandas/core/arrays/timedeltas.py:594: error: Non-overlapping identity check (left operand type: "Timedelta", right operand type: "NaTType") [comparison-overlap]
pandas/core/arrays/timedeltas.py:637: error: Non-overlapping identity check (left operand type: "Timedelta", right operand type: "NaTType") [comparison-overlap]
pandas/core/arrays/timedeltas.py:705: error: Non-overlapping identity check (left operand type: "Timedelta", right operand type: "NaTType") [comparison-overlap]

pandas/core/arrays/masked.py:341: error: Non-overlapping identity check (left operand type: "Union[Union[str, int, float, bool], Union[Period, Timestamp, Timedelta, Interval]]", right operand type: "NoDefault") [comparison-overlap]
pandas/core/arrays/masked.py:349: error: Non-overlapping identity check (left operand type: "Union[Union[str, int, float, bool], Union[Period, Timestamp, Timedelta, Interval]]", right operand type: "NAType") [comparison-overlap]

@twoertwein twoertwein added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member and removed Enhancement labels Oct 28, 2021
@jbrockmendel
Copy link
Member

with the Timedelta one the trouble is that Timedelta.__new__ can return pd.NaT, which is in the timedeltas.pyi file, but mypy complains about so it has a 'type: ignore'

@twoertwein
Copy link
Member Author

Based on codecov, all except these two lines are hit:

pandas/core/arrays/timedeltas.py:637: error: Non-overlapping identity check (left operand type: "Timedelta", right operand type: "NaTType") [comparison-overlap]
pandas/core/arrays/timedeltas.py:705: error: Non-overlapping identity check (left operand type: "Timedelta", right operand type: "NaTType") [comparison-overlap]

I guess this suggests that the type annotations are incorrect in most of the above places.

@twoertwein twoertwein added the Typing type annotations, mypy/pyright type checking label Oct 28, 2021
@twoertwein twoertwein changed the title TYP/CLN: kleene_or/xor/and TYP: Non-overlapping identity checks with pd.NaT Oct 28, 2021
@twoertwein
Copy link
Member Author

Closing this as these are just type issues that can in the simplest case be "solved" by type: ignore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Triage Issue that has not been reviewed by a pandas team member Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

No branches or pull requests

2 participants