Skip to content

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

Closed
@twoertwein

Description

@twoertwein

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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs TriageIssue that has not been reviewed by a pandas team memberTypingtype annotations, mypy/pyright type checking

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions