summaryrefslogtreecommitdiff
path: root/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/utils/typing.py
diff options
context:
space:
mode:
Diffstat (limited to 'venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/utils/typing.py')
-rw-r--r--venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/utils/typing.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/utils/typing.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/utils/typing.py
new file mode 100644
index 0000000..4e25ae6
--- /dev/null
+++ b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/utils/typing.py
@@ -0,0 +1,29 @@
1"""For neatly implementing static typing in pip.
2
3`mypy` - the static type analysis tool we use - uses the `typing` module, which
4provides core functionality fundamental to mypy's functioning.
5
6Generally, `typing` would be imported at runtime and used in that fashion -
7it acts as a no-op at runtime and does not have any run-time overhead by
8design.
9
10As it turns out, `typing` is not vendorable - it uses separate sources for
11Python 2/Python 3. Thus, this codebase can not expect it to be present.
12To work around this, mypy allows the typing import to be behind a False-y
13optional to prevent it from running at runtime and type-comments can be used
14to remove the need for the types to be accessible directly during runtime.
15
16This module provides the False-y guard in a nicely named fashion so that a
17curious maintainer can reach here to read this.
18
19In pip, all static-typing related imports should be guarded as follows:
20
21 from pip.utils.typing import MYPY_CHECK_RUNNING
22
23 if MYPY_CHECK_RUNNING:
24 from typing import ...
25
26Ref: https://github.com/python/mypy/issues/3216
27"""
28
29MYPY_CHECK_RUNNING = False