mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Removes the vendored contextlib2. ExitStack and suppress are available from stdlib contextlib on all supported Python versions. The nullcontext context manager which isn't available in Python 3.6, but the function is simple to implement. Once Python 3.6 support is dropped, so too can the compat shim.
22 lines
586 B
Python
22 lines
586 B
Python
import contextlib
|
|
from typing import Iterator
|
|
|
|
|
|
@contextlib.contextmanager
|
|
def nullcontext():
|
|
# type: () -> Iterator[None]
|
|
"""
|
|
Context manager that does no additional processing.
|
|
|
|
Used as a stand-in for a normal context manager, when a particular block of
|
|
code is only sometimes used with a normal context manager:
|
|
|
|
cm = optional_cm if condition else nullcontext()
|
|
with cm:
|
|
# Perform operation, using optional_cm if condition is True
|
|
|
|
TODO: Replace with contextlib.nullcontext after dropping Python 3.6
|
|
support.
|
|
"""
|
|
yield
|