Skip to content

Fix Type Annotations in pandas.core.arrays #26065

Closed
@gwrome

Description

@gwrome

Part of #25882

Errors in pandas.core.arrays

Type annotations for the following files need to be added or corrected to remove those files from the mypy blacklist:

  • pandas.core.arrays.array_.py
  • pandas.core.arrays.datetimelike.py
  • pandas.core.arrays.integer.py
  • pandas.core.arrays.interval.py
  • pandas.core.arrays.period.py
  • pandas.core.arrays.timedeltas.py

I have started working on these and will make PR soon.

Detailed errors are below.

array_.py

pandas/core/arrays/array_.py:232: error: Item "str" of "Union[str, Any, ExtensionDtype, None]" has no attribute "construct_array_type"
pandas/core/arrays/array_.py:232: error: Item "None" of "Union[str, Any, ExtensionDtype, None]" has no attribute "construct_array_type"

datetimelike.py

pandas/core/arrays/datetimelike.py:367: error: "DatetimeLikeArrayMixin" has no attribute "_data"
pandas/core/arrays/datetimelike.py:482: error: Argument 1 to "len" has incompatible type "Union[int, Sequence[int], Sequence[bool], slice]"; expected "Sized"
pandas/core/arrays/datetimelike.py:486: error: Argument 1 to "len" has incompatible type "Union[int, Sequence[int], Sequence[bool], slice]"; expected "Sized"
pandas/core/arrays/datetimelike.py:487: error: Argument 1 to "len" has incompatible type "Union[int, Sequence[int], Sequence[bool], slice]"; expected "Sized"
pandas/core/arrays/datetimelike.py:503: error: Item "Tuple[Type[Any], ...]" of "Union[Type[Any], Tuple[Type[Any]]]" has no attribute "__name__"
pandas/core/arrays/datetimelike.py:505: error: "DatetimeLikeArrayMixin" has no attribute "_data"

integer.py

pandas/core/arrays/integer.py:34: error: Incompatible types in assignment (expression has type "None", base class "ExtensionDtype" defined the type as "str")
pandas/core/arrays/integer.py:36: error: Incompatible types in assignment (expression has type "None", base class "ExtensionDtype" defined the type as "Type[Any]")

interval.py

pandas/core/arrays/interval.py:946: error: Decorated property not supported

period.py

pandas/core/arrays/period.py:139: error: Need type annotation for '_other_ops'
pandas/core/arrays/period.py:193: error: "PeriodDtype" has no attribute "freq"
pandas/core/arrays/period.py:280: error: Read-only property cannot override read-write property
pandas/core/arrays/period.py:550: error: Unsupported operand type for unary - ("Union[ExtensionArray, Any, Any]")
pandas/core/arrays/period.py:787: error: Incompatible types in assignment (expression has type "None", variable has type "PeriodDtype")

timedeltas.py

pandas/core/arrays/timedeltas.py:134: error: Need type annotation for '_other_ops'
pandas/core/arrays/timedeltas.py:135: error: Need type annotation for '_bool_ops'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Typingtype annotations, mypy/pyright type checking

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions