Skip to content

"pathlib.Path / pd.Series" should be inferred as Series, not as Path #682

Closed
@bersbersbers

Description

@bersbersbers

To Reproduce

  1. Provide a minimal runnable pandas example that is not properly checked by the stubs.
from pathlib import Path

import pandas as pd

folder = Path.cwd()
files = pd.Series(["a.png", "b.png"])
# reveal_type(files)  # good: Series!
paths = folder / files
# reveal_type(paths)  # bad: pathlib.Path!
good_paths = [f if f.is_file() else pd.NA for f in paths]

print(paths)
print(good_paths)
  1. Indicate which type checker you are using (mypy or pyright).
    mypy 1.2.0 (compiled: yes)

  2. Show the error message received from that type checker while checking your example.

bug.py:10: error: "Path" has no attribute "__iter__"; maybe "__enter__"? (not iterable)  [attr-defined]
Found 1 error in 1 file (checked 1 source file)

Please complete the following information:

  • OS: Windows 11
  • OS Version: 22H2
  • python version: 3.10.11
  • version of type checker: 1.2.0
  • version of installed pandas-stubs: 2.0.1.230501

Metadata

Metadata

Assignees

No one assigned

    Labels

    Numeric OperationsArithmetic, Comparison, and Logical operationsStringsString extension data type and string data

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions