Closed cosmicBboy closed 2 years ago
Thanks for reporting this. Apparently you can't use a TypeVar
as an argument in __new__()
. So I created a Union
instead, and now things work.
Might be good to report a minimal example to mypy, pyright doesn't have this issue. (But I'm surprised that pyright's reportInvalidTypeVarUse didn't complain about it.)
Might be good to report a minimal example to mypy, pyright doesn't have this issue. (But I'm surprised that pyright's reportInvalidTypeVarUse didn't complain about it.)
thanks for the quick response @Dr-Irv ! For the time being I've pinned pandas-stubs<=1.4.3.220807
in pandera for now, will unpin it in the next release once this change makes it into a new pandas-stubs release.
thanks for the quick response @Dr-Irv ! For the time being I've pinned
pandas-stubs<=1.4.3.220807
in pandera for now, will unpin it in the next release once this change makes it into a new pandas-stubs release.
I've been pretty steady in doing releases each week, so next one should be on 8/21 or 8/22
@cosmicBboy Just released v1.4.3.220822 that includes the fix for this issue.
Describe the bug
Hi all, first off thanks for this effort! We use
pandas-stubs
in thepandera
project for optional mypy type linting and it's been working great!Recent changes (here) have caused issues in pandera type annotation, where we use a pandera
SchemaModel
in a subclassed DataFrame class like so:However, this will raise a mypy error if
pandas-stubs
is installed:To Reproduce
Consider this code, which subclasses dataframes :
Then using
mypy
:I've isolated the cause of this here, where removing the
ListLike
type annotations (including the one in theIterable
type) makes the error go away. I don't understand why the type annotations in the__new__
method would effect the type of the subclassed generic arguments 🤷♂️Please complete the following information:
pandas-stubs
: 1.4.3.220815Additional context
This issue doesn't show up in the previous version
pandas-stubs==1.4.3.220807