Skip to content

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
Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>
@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

@jbrockmendel jbrockmendel deleted the api-classmethod branch August 10, 2025 16:20
eicchen pushed a commit to eicchen/pandas that referenced this pull request Aug 19, 2025
Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>
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