Skip to content

1.1.395: @overload decorator seems ignored #9984

@lt-brs

Description

@lt-brs

Describe the bug
Newly released version 1.1.395 don't distinguish typing that depends on argument values, using typing overload decorator.
(I apologize if the behavior is the one expected)

Code or Screenshots

Example using pd.read function that output a pd.DataFrame by default and a TextFileReader if argument chunksize is not None .

import pandas as pd

y = pd.read_csv("test.csv")
len(y)

y can only be a DataFrame

pyright output:

backend/pyright_bug_reproduction.py:4:5 - error: Argument of type "DataFrame | TextFileReader" cannot be assigned to parameter "obj" of type "Sized" in function "len"
    Type "DataFrame | TextFileReader" is not assignable to type "Sized"
      "TextFileReader" is incompatible with protocol "Sized"
        "__len__" is not present (reportArgumentType)

pandas version is 2.2.3.

VS Code preview screenshots of types:

Image

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    addressed in next versionIssue is fixed and will appear in next published versionbugSomething isn't workingregression

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions