OILS / vendor / typing.py View on Github | oilshell.org

42 lines, 19 significant
1# Stripped down version of typing.py for runtime support only!
2#
3# We got rid of runtime dependences on collections.py, copy.py, etc.
4#
5# MyPy has its own version of this, since it's written in Python 3. We don't
6# need any support at runtime.
7#
8# If you need to define a type alias, do something like:
9#
10# if TYPE_CHECKING:
11# NullFunc = Callable[[int, int], int]
12
13TypingMeta = None
14TypeVar = None
15_ForwardRef = None
16List = None
17Sequence = None
18Tuple = None
19Optional = None
20Union = None
21IO = None
22Dict = None
23Iterator = None
24Any = None
25NoReturn = None
26Callable = None
27Counter = None # for ID_HIST
28
29Generic = None # for StackArray[T]
30
31TYPE_CHECKING = False
32
33
34def cast(typ, val):
35 """Cast a value to a type.
36
37 This returns the value unchanged. To the type checker this
38 signals that the return value has the designated type, but at
39 runtime we intentionally don't check anything (we want this
40 to be as fast as possible).
41 """
42 return val