Skip to content
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

Include version in deprecation warnings #6218

Conversation

pradyunsg
Copy link
Member

Closes #6216

@pradyunsg pradyunsg added type: enhancement Improvements to functionality type: deprecation Related to deprecation / removal. labels Jan 29, 2019
@pradyunsg pradyunsg self-assigned this Jan 29, 2019
@pradyunsg pradyunsg added the skip news Does not need a NEWS file entry (eg: trivial changes) label Jan 29, 2019
@pradyunsg
Copy link
Member Author

Adding tests for the case when exceptions are raised.

@pradyunsg pradyunsg force-pushed the fix/include-version-in-deprecation-warnings branch from 9263bb4 to eb8b275 Compare January 29, 2019 11:07
@pradyunsg pradyunsg added this to the 19.0 milestone Jan 31, 2019
@pradyunsg
Copy link
Member Author

@cjerdonek Could you take a look at this PR?

Copy link
Member

@cjerdonek cjerdonek left a comment

Choose a reason for hiding this comment

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

Some comments.

@@ -83,8 +83,10 @@ def deprecated(reason, replacement, gone_in, issue=None):
if issue is not None:
url = "https:/pypa/pip/issues/" + str(issue)
message += " You can find discussion regarding this at {}.".format(url)
if gone_in is not None:
message += " pip {} will remove this functionality.".format(gone_in)
Copy link
Member

Choose a reason for hiding this comment

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

I think the most important information should be listed first. So that would be (1) the version in which it was / will be removed, (2) then the replacement, and (3) ending with where to go for more info.

message += " pip {} will remove this functionality.".format(gone_in)
# Raise as an error if it has to be removed.
if parse(current_version) >= parse(gone_in):
raise PipDeprecationWarning(message)
Copy link
Member

Choose a reason for hiding this comment

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

In this case, I would make the message say, "was removed in" instead of "will be."


assert "DEPRECATION: Stop doing this!" in message
# Ensure non-None values are mentioned.
for item in [gone_in, replacement, issue]:
Copy link
Member

@cjerdonek cjerdonek Feb 2, 2019

Choose a reason for hiding this comment

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

With this combinatorial way of testing, it's hard to visualize what the full message looks like, so, in addition to the test testing the various combinations, I would add one separate test with all the information present testing an exact match on the string. That gives maintainers a way to check the message as a whole. I would do one test like this for the exception case and one test for the "will be" case.

@pradyunsg pradyunsg removed this from the 19.0 milestone Feb 3, 2019
@pradyunsg
Copy link
Member Author

This isn't critical path for 19.0.2.

@BrownTruck
Copy link
Contributor

Hello!

I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the master branch into this pull request or rebase this pull request against master then it will be eligible for code review and hopefully merging!

@BrownTruck BrownTruck added the needs rebase or merge PR has conflicts with current master label Mar 2, 2019
@pypa-bot pypa-bot removed the needs rebase or merge PR has conflicts with current master label May 26, 2019
@pradyunsg
Copy link
Member Author

Closing this and creating a new PR because I'm bored.

@pradyunsg pradyunsg closed this May 26, 2019
@pradyunsg pradyunsg deleted the fix/include-version-in-deprecation-warnings branch May 26, 2019 01:37
@pradyunsg
Copy link
Member Author

In this case, I would make the message say, "was removed in" instead of "will be."

The warning getting raised, would only be seen by the maintainers, right? I don't think we need to do this.

@pradyunsg
Copy link
Member Author

because I'm bored.

More because it was easier to copy-paste than fiddle around with git-rebase for such a small PR. I was too lazy to write that.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 26, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation skip news Does not need a NEWS file entry (eg: trivial changes) type: deprecation Related to deprecation / removal. type: enhancement Improvements to functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update pip's deprecation helpers to mention version
4 participants