-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Allow deprecate_nonkeyword_arguments to not specify version, show class name #41524
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
Allow deprecate_nonkeyword_arguments to not specify version, show class name #41524
Conversation
pandas/util/_decorators.py
Outdated
num_allow_args = len(allow_args) | ||
else: | ||
num_allow_args = allow_args | ||
num_allow_args = len(allow_args) |
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.
nbd, but this and the line above could be moved to the outer scope.
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.
indeed - have fixed, thanks!
pandas/util/_decorators.py
Outdated
if len(args) > num_allow_args: | ||
msg = ( | ||
f"Starting with Pandas version {version} all arguments of " | ||
f"{func.__name__}{arguments} will be keyword-only" | ||
f"{future_version_msg(version)} all arguments of " |
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.
same for the message creation
Personally, I think it is good practice to mention the version when it will be removed/changed, so forcing us to do it here is maybe actually fine. |
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.
very minor point (can be in a followup).
@@ -266,14 +269,13 @@ def deprecate_nonkeyword_arguments( | |||
---------- | |||
version : str |
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.
optional
disagree this locks us in, and we don't do this anywhere now. this should be a deliberate decision. |
1) we are already doing this for all other cases of deprecated positional keyword arguments, and 2) this has been decided in our version policy |
Hi @jorisvandenbossche - deprecated positional keyword arguments are quite rare in pandas, there's not been many so far, and most other FutureWarnings don't mention specific versions, e.g. warn(
"The `inplace` parameter in pandas.Categorical."
"set_categories is deprecated and will be removed in "
"a future version. Removing unused categories will always "
"return a new Categorical object.",
FutureWarning,
stacklevel=2,
) It's true that the version policy says
though it doesn't say that warnings should specify versions. I have no preference here though, am happy to go with whatever you all want |
xref #41511 (comment)
as request, ping @jreback @simonjayhawkins
I've removed the ability to pass an integer to
allowed_arguments
as it added complexity, was only used once in the codebase anyway, and wasn't even covered by testsNow, if
version
is None, then it'll just print "In a future version of pandas", it'll show the class name (e.g.Series.drop_duplicates
instead of justdrop_duplicates
) and won't print'self'
in the warning message