Skip to content

Add PendingDeprecationWarning to internal requests methods#1625

Merged
jamesls merged 2 commits intoboto:developfrom
jamesls:vendored-requests-warning
Dec 18, 2018
Merged

Add PendingDeprecationWarning to internal requests methods#1625
jamesls merged 2 commits intoboto:developfrom
jamesls:vendored-requests-warning

Conversation

@jamesls
Copy link
Copy Markdown
Member

@jamesls jamesls commented Dec 11, 2018

This produces no output yet unless you explicitly turn on
warnings. In a future release we'll have this emit a warning
by default.

I opted to put this in the high level botocore.vendored.requests.*
methods because that's the more common usage of requests and I wanted
better error messages. Moving it to the Session.request method
would mean we couldn't give as helpful of an error message.

Testing

$ cat driver.py
from botocore.vendored import requests


print(requests.get('https://httpbin.org'))
print(requests.head('https://httpbin.org'))

$ python driver.py
<Response [200]>
<Response [200]>

$ python -Wd driver.py
/botocore/botocore/vendored/requests/api.py:60: PendingDeprecationWarning: You are using the get() function from 'botocore.vendored.requests'.  This is not a public API in botocore and will be removed in the future. Additionally, this version of requests is out of date.  We recommend you install the requests package, 'import requests' directly, and use the requests.get() function instead.
  PendingDeprecationWarning
<Response [200]>
/botocore/botocore/vendored/requests/api.py:60: PendingDeprecationWarning: You are using the head() function from 'botocore.vendored.requests'.  This is not a public API in botocore and will be removed in the future. Additionally, this version of requests is out of date.  We recommend you install the requests package, 'import requests' directly, and use the requests.head() function instead.
  PendingDeprecationWarning
<Response [200]>

This produces no output yet unless you explicitly turn on
warnings.  In a future release we'll have this emit a warning
by default.

I opted to put this in the high level `botocore.vendored.requests.*`
methods because that's the more common usage of requests and I wanted
better error messages.  Moving it to the `Session.request` method
would mean we couldn't give as helpful of an error message.
@codecov-io
Copy link
Copy Markdown

codecov-io commented Dec 11, 2018

Codecov Report

Merging #1625 into develop will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #1625   +/-   ##
========================================
  Coverage    91.99%   91.99%           
========================================
  Files           51       51           
  Lines         9335     9335           
========================================
  Hits          8588     8588           
  Misses         747      747

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d286246...2092de2. Read the comment docs.

"""
warnings.warn(
_WARNING_MSG.format(name=method),
PendingDeprecationWarning
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be DeprecationWarning since it's already deprecated. Though I'm not sure deprecated is right at all since this was never meant to be used in the first place. Might be better to stick with UserWarning since that will be shown by default.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm, I think either PendingDeprecationWarning or DeprecationWarning is appropriate.
I'm -1 on labeling this as a UserWarning just to get it to show up by default, as I think it would go against what users would expect of a deprecation warning.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Let's switch it to DeprecationWarning for now. I think we'll eventually convert this to a warning that shows up by default, but I want to put something in place now and let it sit for a while before we start printing warnings to stderr.

Copy link
Copy Markdown
Contributor

@joguSD joguSD left a comment

Choose a reason for hiding this comment

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

Do you think it would be possible to put this in the Session constructor instead? That way if they're going through the shortcuts or managing the Session object themselves they'll still get warned.

"""
warnings.warn(
_WARNING_MSG.format(name=method),
PendingDeprecationWarning
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm, I think either PendingDeprecationWarning or DeprecationWarning is appropriate.
I'm -1 on labeling this as a UserWarning just to get it to show up by default, as I think it would go against what users would expect of a deprecation warning.

@jamesls
Copy link
Copy Markdown
Member Author

jamesls commented Dec 13, 2018

@joguSD so my main concern was with trying to get a decent error message. Putting in the Session.request would catch cases where you're using a session directly at the cost of a more generic error message. Perhaps once we start printing warnings by default we can also add it to the Session.request method?

Copy link
Copy Markdown
Contributor

@joguSD joguSD left a comment

Choose a reason for hiding this comment

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

@jamesls Makes sense to me.

@jamesls jamesls merged commit 2092de2 into boto:develop Dec 18, 2018
jamesls added a commit that referenced this pull request Dec 18, 2018
PR #1625

* vendored-requests-warning:
  Change PendingDeprecationWarning to DeprecationWarning
  Add PendingDeprecationWarning to internal requests methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants