C preprocessor written in Python
Revisão | 8ef443b978cf4b05abdd8c08c1fc6c85e74ffc7b (tree) |
---|---|
Hora | 2022-02-01 14:45:47 |
Autor | Eric Hopper <hopper@omni...> |
Commiter | Eric Hopper |
Fix syntax errors in type hints, remove commented out code.
@@ -17,30 +17,6 @@ | ||
17 | 17 | T = TypeVar("T") |
18 | 18 | |
19 | 19 | |
20 | -# class _SequenceRef(ReferenceType["LazySequence"[T]]): | |
21 | -# def __init__( | |
22 | -# self, | |
23 | -# sequence: "LazySequence"[T], | |
24 | -# state: "_LazySequenceState"[T], | |
25 | -# **kwargs | |
26 | -# ): | |
27 | -# super().__init__(self, sequence, state._refdestroyed) | |
28 | -# | |
29 | -# def __cmp__(self, other_ref: "_SequenceRef"[T]) -> int: | |
30 | -# me = self() | |
31 | -# other = other_ref() | |
32 | -# if (me, other) is (None, None): | |
33 | -# return id(self) - id(other_ref) | |
34 | -# elif me is None: | |
35 | -# return -1 | |
36 | -# elif other is None: | |
37 | -# return 1 | |
38 | -# else: # me and other are both not None | |
39 | -# cmpval: int = me.index - other.index | |
40 | -# if cmpval == 0: | |
41 | -# cmpval = id(self) - id(other_ref) | |
42 | -# return cmpval | |
43 | - | |
44 | 20 | class _LazySequenceState(Generic[T]): |
45 | 21 | def __init__(self, item_iterator: Iterator[T], **kwargs): |
46 | 22 | super().__init__(**kwargs) |
@@ -49,7 +25,7 @@ | ||
49 | 25 | self.heads: List[ReferenceType[T]]= [] |
50 | 26 | self.index_of_0: int = 0 |
51 | 27 | |
52 | - def new_sequence(self, sequence: "LazySequence"[T]) -> None: | |
28 | + def new_sequence(self, sequence: "LazySequence[T]") -> None: | |
53 | 29 | assert sequence.state is self |
54 | 30 | if sequence.index < self.index_of_0: |
55 | 31 | raise RuntimeError("LazySequence created that's attempting to time " |
@@ -89,7 +65,7 @@ | ||
89 | 65 | |
90 | 66 | |
91 | 67 | class LazySequence(Sequence[T]): |
92 | - def __init__(self, item_iterator: Union["LazySequence", Iterable[T]], **kwargs): | |
68 | + def __init__(self, item_iterator: Union["LazySequence[T]", Iterable[T]], **kwargs): | |
93 | 69 | if isinstance(item_iterator, LazySequence): |
94 | 70 | self.state = item_iterator.state |
95 | 71 | self.index = item_iterator.index |
@@ -105,7 +81,7 @@ | ||
105 | 81 | raise NotImplemented("Lazy sequences may be infinitely long.") |
106 | 82 | |
107 | 83 | def __getitem__(self, index: Union[int, slice]) \ |
108 | - -> Union[T, "LazySequence"[T], List[T]]: | |
84 | + -> Union[T, "LazySequence[T]", List[T]]: | |
109 | 85 | if index < 0: |
110 | 86 | raise ValueError("Lazy sequences may not have an end and don't " |
111 | 87 | "support indexing from the end.") |