-
-
Notifications
You must be signed in to change notification settings - Fork 18k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TYP: Narrow down types of arguments (DataFrame) #52752
TYP: Narrow down types of arguments (DataFrame) #52752
Conversation
Specify parser in to_xml of class dataframe Update doc string to_orc in class dataframeUpdate doc string to_orc in class dataframe Specify engine in to_parquet in class dataframe
…e argument of join and merge method Change byteorder argument typing for to_stata method to literal, added definition in pandas/_typing.py Change if_exists argument typing for to_gbq method to literal, added definition in pandas/_typing.py Change orient argument typing for from_dict method to literal, added definition in pandas/_typing.py Change how argument typing for to_timestamp method to literal, added definition in pandas/_typing.py Change validate argument typing for merge and join methods to literal, added definition in pandas/_typing.py Change na_action arguments typing for applymap method to literal, added definition in pandas/_typing.py Change join and errors arguments typing for update method to litaral, added definition in pandas/_typing.py Change keep argument typing for nlargest and nsallest to litaera, added definition in pandas/_typing.py Specify the kind and na_position more precisely in sort_values, reusing type definitions in pandas/_typing.py
…er/pandas into origin/narrow_down_types_frame_bm
pandas/_typing.py
Outdated
# applymap | ||
NaAction = Literal["None", "ignore"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for your pr
this isn't quite right, you can't pass "None"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry for that, resolved in 7e1c7c9
…ov substitution principle otherwise
…ov substitution principle otherwise
Help, @phofl - i keep getting a mypy error
this is completely new to me, so I do not have any idea how to fix that. Could you help out, please? |
@benedikt-mangold: Since we changed |
This is an annoying case… You can add „ type: ignore[assignment]“ after the lower in the same line. no we would have to deprecate first, which is something I’d be open to do. But not in this pr (we try to keep things separated) |
@pschleiter and @phofl -> worked, build is green 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you merge main to resolve conflicts? otherwise lgtm
@pschleiter and @phofl - halp -> why on earth would it be red now ?? |
merging did not contain all changes in .typing.py |
@phofl ready to merge 🎉 |
Thanks @benedikt-mangold |
closes #8 (noatamir/pyladies-workshop#8)
Tests added and passed if fixing a bug or adding a new feature
All code checks passed.
Added type annotations to new arguments/methods/functions.
Preview discussion:
We prefer using Literal["a"] | Literal["b"] instead of str. Look into the documentation what is allowed and the narrow the types down appropriately. Generally, we probably already have type definitions in pandas/_typing.py like NaPosition for the first item in the list below.
You can locate the appropriate file through searching for class DataFrame in the repository.
DataFrame methods:
#Reviewers
@phofl @noatamir @jorisvandenbossche and @MarcoGorelli