|
| 1 | +from __future__ import annotations |
| 2 | + |
1 | 3 | import types |
2 | 4 | from collections import defaultdict |
3 | 5 | from dataclasses import dataclass |
@@ -36,7 +38,7 @@ def __init__( |
36 | 38 | ] = None, |
37 | 39 | ) -> None: |
38 | 40 | # a BasicBlock object, or None |
39 | | - self.next_block: Optional["BasicBlock"] = None |
| 41 | + self.next_block: Optional[BasicBlock] = None |
40 | 42 | if instructions: |
41 | 43 | super().__init__(instructions) |
42 | 44 |
|
@@ -129,7 +131,7 @@ def legalize(self, first_lineno: int) -> int: |
129 | 131 |
|
130 | 132 | return current_lineno |
131 | 133 |
|
132 | | - def get_jump(self) -> Optional["BasicBlock"]: |
| 134 | + def get_jump(self) -> Optional[BasicBlock]: |
133 | 135 | if not self: |
134 | 136 | return None |
135 | 137 |
|
@@ -243,7 +245,7 @@ def __init__( |
243 | 245 | self.pending_try_begin = pending_try_begin |
244 | 246 | self._current_try_begin = pending_try_begin |
245 | 247 |
|
246 | | - def run(self) -> Generator[Union["_StackSizeComputer", int], int, None]: |
| 248 | + def run(self) -> Generator[Union[_StackSizeComputer, int], int, None]: |
247 | 249 | """Iterate over the block instructions to compute stack usage.""" |
248 | 250 | # Blocks are not hashable but in this particular context we know we won't be |
249 | 251 | # modifying blocks in place so we can safely use their id as hash rather than |
@@ -430,7 +432,7 @@ def _update_size(self, pre_delta: int, post_delta: int) -> None: |
430 | 432 |
|
431 | 433 | def _compute_exception_handler_stack_usage( |
432 | 434 | self, block: BasicBlock, push_lasti: bool |
433 | | - ) -> Generator[Union["_StackSizeComputer", int], int, None]: |
| 435 | + ) -> Generator[Union[_StackSizeComputer, int], int, None]: |
434 | 436 | b_id = id(block) |
435 | 437 | if self.minsize < self.common.exception_block_startsize[b_id]: |
436 | 438 | block_size = yield _StackSizeComputer( |
@@ -741,7 +743,7 @@ def get_dead_blocks(self) -> List[BasicBlock]: |
741 | 743 | return [b for b in self if id(b) not in seen_block_ids] |
742 | 744 |
|
743 | 745 | @staticmethod |
744 | | - def from_bytecode(bytecode: _bytecode.Bytecode) -> "ControlFlowGraph": |
| 746 | + def from_bytecode(bytecode: _bytecode.Bytecode) -> ControlFlowGraph: |
745 | 747 | # label => instruction index |
746 | 748 | label_to_block_index = {} |
747 | 749 | jumps = [] |
|
0 commit comments