Skip to content

Is ExtensionDtype.type a property or a ClassVar? #51736

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

Closed
wants to merge 1 commit into from
Closed

Is ExtensionDtype.type a property or a ClassVar? #51736

wants to merge 1 commit into from

Conversation

twoertwein
Copy link
Member

ExtensionDtype.type is a property but a few (not all) sub-classes define it as a class variable. I assume it should be a property but I'm not sure.

There are a few more cases where type is used a class variable in pandas/core/arrays/floating.py and pandas/core/arrays/integer.py. I will address them but I first wanted to ask whether type is supposed to be a property or a class variable. @jbrockmendel

xref pandas-dev/pandas-stubs#554 (comment)

@twoertwein twoertwein marked this pull request as draft March 2, 2023 02:40
@jbrockmendel
Copy link
Member

Either way. I like the class-level when it is fixed bc it is less verbose. It's also faster to access (37ns vs 62ns not a huge deal but still)

The only way I can imagine it making a difference at runtime is if a user tries to modify it, which is a corner case im not inclined to defined against.

If you feel strongly about aligning these for type-checking reasons, fine by me.

@twoertwein
Copy link
Member Author

Either way. I like the class-level when it is fixed bc it is less verbose. It's also faster to access (37ns vs 62ns not a huge deal but still)

Happy to go with a ClassVar everywhere

@mroeschke mroeschke added the Typing type annotations, mypy/pyright type checking label Mar 6, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Apr 6, 2023

This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this.

@github-actions github-actions bot added the Stale label Apr 6, 2023
@twoertwein twoertwein closed this Apr 6, 2023
@twoertwein twoertwein deleted the class_property branch August 9, 2023 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stale Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants