Skip to content

Commit

Permalink
Remove contextlib.nullcontext compat shim in favor of pip's version
Browse files Browse the repository at this point in the history
This removes the need to maintain yet another compatibility shim that is
already handled by pip. pip has a vendored copy of contextlib2, which
contains the same copy of the function.

At some point in the future, pip-tools can use the stdlib version
instead.
  • Loading branch information
jdufresne committed Jan 1, 2021
1 parent 61cb487 commit 0036708
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
18 changes: 0 additions & 18 deletions piptools/_compat/contextlib.py

This file was deleted.

5 changes: 3 additions & 2 deletions piptools/repositories/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
from pip._internal.utils.misc import normalize_path
from pip._internal.utils.temp_dir import TempDirectory, global_tempdir_manager
from pip._internal.utils.urls import path_to_url, url_to_path
from pip._vendor import contextlib2
from pip._vendor.requests import RequestException

from .._compat import PIP_VERSION, contextlib
from .._compat import PIP_VERSION
from ..click import progressbar
from ..exceptions import NoCandidateFound
from ..logging import log
Expand Down Expand Up @@ -407,7 +408,7 @@ def _get_file_hash(self, link):
width=32,
)
else:
context_manager = contextlib.nullcontext(chunks)
context_manager = contextlib2.nullcontext(chunks)

# Iterate over the chosen context manager
with context_manager as bar:
Expand Down

0 comments on commit 0036708

Please sign in to comment.