Skip to content

Mypy reports issues with to_string on Series that seem erroneous #720

Closed
@mattinbits

Description

@mattinbits

Describe the bug
When calling to_string on Series with index=False, mypy reports that this is not a valid variant, although it looks ok.

To Reproduce

Minimal example:

import pandas as pd

s = pd.Series(["A", "B", "C"])
print(s.to_string())
print(s.to_string(index=False))

mypy example.py

example.py:5: error: No overload variant of "to_string" of "Series" matches argument type "bool"  [call-overload]
example.py:5: note: Possible overload variants:
example.py:5: note:     def to_string(self, buf: Union[str, PathLike[str], WriteBuffer[str]], na_rep: str = ..., formatters: Any = ..., float_format: Any = ..., sparsify: Optional[bool] = ..., index_names: bool = ..., justify: Optional[str] = ..., max_rows: Optional[int] = ..., min_rows: Optional[int] = ..., max_cols: Optional[int] = ..., show_dimensions: bool = ..., decimal: str = ..., line_width: Optional[int] = ..., max_colwidth: Optional[int] = ..., encoding: Optional[str] = ...) -> None
example.py:5: note:     def to_string(self, buf: None = ..., na_rep: str = ..., formatters: Any = ..., float_format: Any = ..., sparsify: Optional[bool] = ..., index_names: bool = ..., justify: Optional[str] = ..., max_rows: Optional[int] = ..., min_rows: Optional[int] = ..., max_cols: Optional[int] = ..., show_dimensions: bool = ..., decimal: str = ..., line_width: Optional[int] = ..., max_colwidth: Optional[int] = ..., encoding: Optional[str] = ...) -> str

Please complete the following information:

  • OS: Linux
  • OS Version: Ubuntu 20.04
  • python version: 3.9.14
  • version of type checker: mypy 1.3.0
  • version of installed pandas-stubs: 2.0.1.230501
  • version of pandas: 2.0.1

Additional context
Nothing else to add

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions