Describe the bug
When creating a series from a TypedDict, Pyright reports
No overloads for "__new__" match the provided arguments. Argument of type (TypedDict) cannot be assigned to parameter "data" of type "Scalar | _ListLike[Unknown] | dict[HashableT1@__new__, Any] | BaseGroupBy[Unknown] | NaTType | NAType | None" in function "__new__"
To Reproduce
from typing import TypedDict
import pandas as pd
class MyDict(TypedDict):
a: str
b: str
my_dict = MyDict(a="", b="")
pd.Series(my_dict)
Pyright yields
error: No overloads for "__new__" match the provided arguments (reportCallIssue)
error: Argument of type "MyDict" cannot be assigned to parameter "data" of type "Scalar | _ListLike[Unknown] | dict[HashableT1@__new__, Any] | BaseGroupBy[Unknown] | NaTType | NAType | None" in function "__new__"
Type "MyDict" is incompatible with type "Scalar | _ListLike[Unknown] | dict[HashableT1@__new__, Any] | BaseGroupBy[Unknown] | NaTType | NAType | None"
"MyDict" is incompatible with "ExtensionArray"
"MyDict" is incompatible with "NAType"
"MyDict" is incompatible with "NaTType"
"MyDict" is incompatible with "Timedelta"
"MyDict" is incompatible with "Timestamp"
"MyDict" is incompatible with "bool"
"MyDict" is incompatible with "bytes"
... (reportArgumentType)
Please complete the following information:
OS: Linux
OS Version: 22
python version: Python 3.12.4
version of type checker: Pyright 1.1.374
version of installed pandas-stubs: 2.2.2.240603
Additional context
Seems like TypedDict is incompatible with dict, but I don't see why it matters in this specific example. Changing overload 8 (series.pyi(332, 9))
Describe the bug When creating a series from a TypedDict, Pyright reports
No overloads for "__new__" match the provided arguments. Argument of type (TypedDict) cannot be assigned to parameter "data" of type "Scalar | _ListLike[Unknown] | dict[HashableT1@__new__, Any] | BaseGroupBy[Unknown] | NaTType | NAType | None" in function "__new__"
To Reproduce
Pyright yields
Please complete the following information:
pandas-stubs
: 2.2.2.240603Additional context Seems like
TypedDict
is incompatible withdict
, but I don't see why it matters in this specific example. Changing overload 8 (series.pyi(332, 9))to
fixes this specific example but I don't know if it breaks something elsewhere.