Skip to content

BUG: Improve error message when ExtensionDtype subclass missing 'name' attribute#65299

Open
avasis-ai wants to merge 1 commit intopandas-dev:mainfrom
avasis-ai:fix-extension-dtype-name-assertion
Open

BUG: Improve error message when ExtensionDtype subclass missing 'name' attribute#65299
avasis-ai wants to merge 1 commit intopandas-dev:mainfrom
avasis-ai:fix-extension-dtype-name-assertion

Conversation

@avasis-ai
Copy link
Copy Markdown

Fixes #46093

When an ExtensionDtype subclass does not define a name class attribute (or defines it as a non-string), construct_from_string would fail with an unhelpful AssertionError: (<class '__main__.FooType'>, <class 'property'>).

This replaces the assert isinstance(cls.name, str) with a proper TypeError that clearly names the subclass and explains that the name attribute must be a string class attribute.

When an ExtensionDtype subclass does not define a 'name' class attribute,
construct_from_string would fail with an unhelpful AssertionError. Replace
with a clear TypeError that names the subclass and explains the requirement.
@jbrockmendel
Copy link
Copy Markdown
Member

Does this need a test? Does this address the comments in the motivating issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Exception for ExtensionDtype with missing attributes not very helpful

3 participants