Skip to content

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

Merged

Conversation

MarcoGorelli
Copy link
Member

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 tests

Now, 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 just drop_duplicates) and won't print 'self' in the warning message

num_allow_args = len(allow_args)
else:
num_allow_args = allow_args
num_allow_args = len(allow_args)
Copy link
Member

@simonjayhawkins simonjayhawkins May 17, 2021

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed - have fixed, thanks!

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 "
Copy link
Member

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

@simonjayhawkins simonjayhawkins added the Deprecate Functionality to remove in pandas label May 17, 2021
@jorisvandenbossche
Copy link
Member

Now, if version is None, then it'll just print "In a future version of pandas"

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.

Copy link
Contributor

@jreback jreback left a 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional

@jreback jreback added this to the 1.3 milestone May 18, 2021
@jreback jreback merged commit f3cce60 into pandas-dev:master May 18, 2021
@jreback
Copy link
Contributor

jreback commented May 18, 2021

Now, if version is None, then it'll just print "In a future version of pandas"

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.

disagree this locks us in, and we don't do this anywhere now. this should be a deliberate decision.

@MarcoGorelli MarcoGorelli deleted the fixup-deprecate-nonkeyword-args branch May 18, 2021 21:11
@jorisvandenbossche
Copy link
Member

jorisvandenbossche commented May 19, 2021

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

@MarcoGorelli
Copy link
Member Author

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

Deprecations will only be enforced in major releases. For example, if a
behavior is deprecated in pandas 1.2.0, it will continue to work, with a
warning, for all releases in the 1.x series. The behavior will change and the
deprecation removed in the next major release (2.0.0).

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

TLouf pushed a commit to TLouf/pandas that referenced this pull request Jun 1, 2021
JulianWgs pushed a commit to JulianWgs/pandas that referenced this pull request Jul 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants