You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The pd.Series class is making use of a constrained TypeVar. I'm not sure why this was done, but it's almost certainly not the right approach. A constrained TypeVar is rarely the right tool — and that's especially true when it comes to class-scoped type variables. There are many reasons why a constrained TypeVar is problematic, but to give you one example... A Series is able to contain heterogeneous types, but a constrained TypeVar doesn't permit something like Series[int | str]. I recommend that you switch from a constrained TypeVar to a regular TypeVar with a bound that is a union. Not only will this more correctly model the way Series works in pandas, it will also avoid the many bugs that mypy has with constrained TypeVars. I see that constrained TypeVars are used in a number of locations within the pandas stubs. I recommend looking at each of these uses and considering whether there's a better approach.
We should investigate whether we can change all TypeVar that have a list of types to refer to a Union of those types instead, with the bound argument. It works fine for S1 in #716
The text was updated successfully, but these errors were encountered:
See comment 3 in microsoft/pyright#5178 (comment)
We should investigate whether we can change all
TypeVar
that have a list of types to refer to aUnion
of those types instead, with thebound
argument. It works fine forS1
in #716The text was updated successfully, but these errors were encountered: