creeper-adventure/.venv/lib/python3.8/site-packages/mypy/state.py
2022-03-31 20:20:07 -05:00

20 lines
519 B
Python

from contextlib import contextmanager
from typing import Optional, Tuple, Iterator
# These are global mutable state. Don't add anything here unless there's a very
# good reason.
# Value varies by file being processed
strict_optional = False
find_occurrences: Optional[Tuple[str, str]] = None
@contextmanager
def strict_optional_set(value: bool) -> Iterator[None]:
global strict_optional
saved = strict_optional
strict_optional = value
try:
yield
finally:
strict_optional = saved