-
Notifications
You must be signed in to change notification settings - Fork 306
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
Avoid DeprecationWarning from urllib3 #719
Conversation
twine/repository.py
Outdated
return adapters.HTTPAdapter(max_retries=retry) | ||
|
||
# method_whitelist will be removed in 2.0; avoid DeprecationWarning until then | ||
urllib3_version = importlib_metadata.version("urllib3") |
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.
Please let's not check the version like this. Why not just do something simple like:
try:
retry = urllib3.Retry(allowed_methods=["GET"], **retry_kwargs)
except TypeError:
# NOTE remove once urllib3 1.26 is the minimum version
retry = urllib3.Retry(method_whitelist=["GET"], **retry_kwargs)
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.
🤦♂️ This is much better, thanks. Done.
|
||
try: | ||
retry = urllib3.Retry(allowed_methods=["GET"], **retry_kwargs) | ||
except TypeError: # pragma: no cover |
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.
I tested this locally, via b07f7db. But -e py36
isn't run by the GitHub Action; instead, it runs -e py
to use the job's matrix.python
version:
twine/.github/workflows/main.yml
Lines 40 to 52 in fd57198
matrix: | |
python: [3.6, 3.7, 3.8, 3.9] | |
platform: [ubuntu-latest, macos-latest, windows-latest] | |
runs-on: ${{ matrix.platform }} | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: Install dependencies | |
run: python -m pip install tox | |
- name: Run tests | |
run: python -m tox -e py -- --cov-report xml |
With that in mind, this felt like a reasonable time to use no cover
.
When running tests, I've started to see:
For details, see:
This is an attempt to silence that warning, while remaining flexible on the version of
urllib3
. I'm guessing there are other (possibly preferable) approaches. For example, we could requireurllib3<2
, and suppress the warning.