Skip to content

API: make construct_array_type non-classmethod #62060

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 2 commits into from
Aug 6, 2025

Conversation

jbrockmendel
Copy link
Member

Makes the method robust to the possibility of keywords (e.g. na_value, storage) that determine what EA subclass you get. StringDtype already does this.

@jbrockmendel jbrockmendel marked this pull request as ready for review August 6, 2025 15:10
@@ -150,7 +150,7 @@ def _coerce_to_data_and_mask(
if dtype is not None:
dtype = dtype_cls._standardize_dtype(dtype)

cls = dtype_cls.construct_array_type()
cls = dtype_cls().construct_array_type()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Is it possible to change _coerce_to_data_and_mask to pass an dtype instance here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats slightly more invasive since it means updating the annotations etc

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK good for a follow up then. Would like to avoid always assuming here that it's safe to instantiate these types with no arguments

@mroeschke mroeschke added the ExtensionArray Extending pandas with custom dtypes or arrays. label Aug 6, 2025
@mroeschke mroeschke added this to the 3.0 milestone Aug 6, 2025
@mroeschke mroeschke merged commit fcd2a5d into pandas-dev:main Aug 6, 2025
43 checks passed
@mroeschke
Copy link
Member

Thanks @jbrockmendel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ExtensionArray Extending pandas with custom dtypes or arrays.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

REF/API: make construct_array_type a non-classmethod
2 participants