Skip to content

Commit

Permalink
Avoid DeprecationWarning from urllib3 (#719)
Browse files Browse the repository at this point in the history
* Avoid DeprecationWarning from urllib3

* Don't use a version check

* Add coverage of deprecated kwarg

* Skip deprecation coverage
  • Loading branch information
bhrutledge authored Nov 29, 2020
1 parent fd57198 commit 35e40d9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions twine/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,19 @@ def __init__(

@staticmethod
def _make_adapter_with_retries() -> adapters.HTTPAdapter:
retry = urllib3.Retry(
retry_kwargs = dict(
connect=5,
total=10,
method_whitelist=["GET"],
status_forcelist=[500, 501, 502, 503],
)

try:
retry = urllib3.Retry(allowed_methods=["GET"], **retry_kwargs)
except TypeError: # pragma: no cover
# Avoiding DeprecationWarning starting in urllib3 1.26
# Remove when that's the mininum version
retry = urllib3.Retry(method_whitelist=["GET"], **retry_kwargs)

return adapters.HTTPAdapter(max_retries=retry)

@staticmethod
Expand Down

0 comments on commit 35e40d9

Please sign in to comment.