Skip to content

Commit ced655e

Browse files
committed
add shim for nullcontext
1 parent cb1ebcd commit ced655e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

mypy/checkexpr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Expression type checker. This file is conceptually part of TypeChecker."""
2-
2+
from mypy.nullcontext import nullcontext
33
from mypy.ordered_dict import OrderedDict
4-
from contextlib import contextmanager, nullcontext
4+
from contextlib import contextmanager
55
import itertools
66
from typing import (
77
Any, cast, Dict, Set, List, Tuple, Callable, Union, Optional, Sequence, Iterator

mypy/nullcontext.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import sys
2+
from contextlib import contextmanager
3+
from typing import Iterator
4+
5+
if sys.version_info < (3, 7):
6+
@contextmanager
7+
def nullcontext() -> Iterator[None]:
8+
yield
9+
else:
10+
from contextlib import nullcontext as nullcontext, contextmanager # noqa: F401

0 commit comments

Comments
 (0)