An implementation of upcast
#6779
Azureblade3808
started this conversation in
Show and tell
Replies: 1 comment 1 reply
-
Feel free to report pandas-stubs issues here: https://github.com/pandas-dev/pandas-stubs If you prefer the pandas annotations (compared to the pandas-stubs annotations), you can simply uninstall pandas-stubs: pyright should(?) then use the non-py.typed pandas annotations and infer any missing annotations. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I use Pandas in my daily work. Sometimes I want to erase generic types provided by "pandas-stubs" (e.g., convert
Series[bool]
intoSeries
), as the types there don't seem right. I used to usetyping.cast
to have the job done but I've written some bugs caused by some wrong casts (e.g.,cast("pd.Series", df.iloc[0:])
instead ofcast("pd.Series", df.iloc[0])
) . Now I have implementedupcast
to avoid such bugs.It can be used with something like
upcast[TYPE_OR_TYPE_STRING](value)
. For example ---and
Related: #1261
Edit:
Add a custom
__class_getitem__
to prevent some unexpected errors with calls likeupcast["int"](int)
.Beta Was this translation helpful? Give feedback.
All reactions