Skip to content

API: make construct_array_type non-optional #41862

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

Merged
merged 3 commits into from
Jun 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.3.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,7 @@ Other API changes
- Accessing ``_constructor_expanddim`` on a :class:`DataFrame` and ``_constructor_sliced`` on a :class:`Series` now raise an ``AttributeError``. Previously a ``NotImplementedError`` was raised (:issue:`38782`)
- Added new ``engine`` and ``**engine_kwargs`` parameters to :meth:`DataFrame.to_sql` to support other future "SQL engines". Currently we still only use ``SQLAlchemy`` under the hood, but more engines are planned to be supported such as ``turbodbc`` (:issue:`36893`)
- Removed redundant ``freq`` from :class:`PeriodIndex` string representation (:issue:`41653`)
- :meth:`ExtensionDtype.construct_array_type` is now a required method instead of an optional one for :class:`ExtensionDtype` subclasses (:issue:`24860`)

Build
=====
Expand Down
9 changes: 2 additions & 7 deletions pandas/core/dtypes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class ExtensionDtype:

* type
* name
* construct_array_type

The following attributes and methods influence the behavior of the dtype in
pandas operations
Expand All @@ -56,12 +57,6 @@ class ExtensionDtype:
* _is_boolean
* _get_common_dtype

Optionally one can override construct_array_type for construction
with the name of this dtype via the Registry. See
:meth:`extensions.register_extension_dtype`.

* construct_array_type

The `na_value` class attribute can be used to set the default NA value
for this type. :attr:`numpy.nan` is used by default.

Expand Down Expand Up @@ -210,7 +205,7 @@ def construct_array_type(cls) -> type_t[ExtensionArray]:
-------
type
"""
raise NotImplementedError
raise AbstractMethodError(cls)

@classmethod
def construct_from_string(cls, string: str):
Expand Down