compat: workaround for Literal to work in runtime in python<3.8

previously it would crash with:
   SyntaxError: Forward reference must be an expression -- got 'yield'

(reproducible via python3 -c 'from typing import Union; Union[int, "yield"]' )
This commit is contained in:
Dima Gerasimov 2022-04-15 22:46:01 +01:00 committed by karlicoss
parent 382f205429
commit 6e921627d3

View file

@ -58,9 +58,11 @@ else:
if TYPE_CHECKING:
from typing_extensions import Literal
else:
from typing import Union
# erm.. I guess as long as it's not crashing, whatever...
Literal = Union
class _Literal:
def __getitem__(self, args):
pass
Literal = _Literal()
import os