Skip to content
Open
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
8 changes: 5 additions & 3 deletions pandas/core/dtypes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,11 @@ def construct_from_string(cls, string: str) -> Self:
raise TypeError(
f"'construct_from_string' expects a string, got {type(string)}"
)
# error: Non-overlapping equality check (left operand type: "str", right
# operand type: "Callable[[ExtensionDtype], str]") [comparison-overlap]
assert isinstance(cls.name, str), (cls, type(cls.name))
if not isinstance(cls.name, str):
raise TypeError(
f"ExtensionDtype subclass {cls.__name__} must define a 'name' "
f"class attribute as a string, got {type(cls.name).__name__}"
)
if string != cls.name:
raise TypeError(f"Cannot construct a '{cls.__name__}' from '{string}'")
return cls()
Expand Down
Loading