Skip to content

Commit 92d9030

Browse files
author
hauntsaninja
committed
stubtest: work around a bug in early versions of py35
1 parent d1bf9bb commit 92d9030

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

mypy/stubtest.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,17 @@ def __repr__(self) -> str:
3636
MISSING = Missing()
3737

3838
T = TypeVar("T")
39-
MaybeMissing = Union[T, Missing]
39+
if sys.version_info >= (3, 5, 3):
40+
MaybeMissing = Union[T, Missing]
41+
else:
42+
# work around a bug in 3.5.2 and earlier's typing.py
43+
class MaybeMissingMeta(type):
44+
def __getitem__(self, arg: Any) -> Any:
45+
return Union[arg, Missing]
46+
47+
class MaybeMissing(metaclass=MaybeMissingMeta): # type: ignore
48+
pass
49+
4050

4151
_formatter = FancyFormatter(sys.stdout, sys.stderr, False)
4252

0 commit comments

Comments
 (0)