Skip to content

Commit

Permalink
#148 Fix type narrowing in get_dtype
Browse files Browse the repository at this point in the history
  • Loading branch information
astropenguin committed Jan 7, 2023
1 parent 04bcdf5 commit e981275
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pandas_dataclasses/core/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ def get_nontags(tp: Any, bound: Tag = Tag.ANY) -> List[Any]:

def get_dtype(tp: Any) -> Optional[str]:
"""Extract a data type of NumPy or pandas from a type hint."""
if (tagged := get_tagged(tp, Tag.DATA | Tag.INDEX)) is None:
if (tp := get_tagged(tp, Tag.DATA | Tag.INDEX, True)) is None:
return None

if (dtype := get_tagged(tagged, Tag.DTYPE)) is None:
if (dtype := get_tagged(tp, Tag.DTYPE)) is None:
return None

if dtype is Any or dtype is type(None):
Expand Down

0 comments on commit e981275

Please sign in to comment.