Skip to content

TYP: Series.name is Hashable - should it be str? #42534

Closed
@Dr-Irv

Description

@Dr-Irv
  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


import pandas as pd

s = pd.Series([1,2,3], name="foo")

reveal_type(s.name)

nam: str = s.name

mypy then reports:

seriesnam.py:5: note: Revealed type is "typing.Hashable*"
seriesnam.py:7: error: Incompatible types in assignment (expression has type "Hashable", variable has type "str")  [assignment]

It's natural to assume that the names of a Series are str

So why do we have it typed as Hashable ?

Seems like @simonjayhawkins changed this in #39107

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugClosing CandidateMay be closeable, needs more eyeballsTypingtype annotations, mypy/pyright type checking

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions