summaryrefslogtreecommitdiff
path: root/python/highlevelil.py
diff options
context:
space:
mode:
authorJosh Ferrell <josh@vector35.com>2024-04-21 22:05:45 -0400
committerJosh Ferrell <josh@vector35.com>2024-04-21 22:08:46 -0400
commit72cb4b08ac8f7c9261867cd6c0b18c054d73b96e (patch)
tree8071e25bb466cb78ee2fab70d1224aab494a250f /python/highlevelil.py
parent32560285ef48669582b90e046d1920a957630ae0 (diff)
Improve type hints for many __getitem__ impls
Diffstat (limited to 'python/highlevelil.py')
-rw-r--r--python/highlevelil.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/python/highlevelil.py b/python/highlevelil.py
index 2b4d9153..79ac7366 100644
--- a/python/highlevelil.py
+++ b/python/highlevelil.py
@@ -20,7 +20,7 @@
import ctypes
import struct
-from typing import Optional, Generator, List, Union, NewType, Tuple, ClassVar, Mapping, Set, Callable, Any, Iterator
+from typing import Optional, Generator, List, Union, NewType, Tuple, ClassVar, Mapping, Set, Callable, Any, Iterator, overload
from dataclasses import dataclass
from enum import Enum
@@ -3089,7 +3089,13 @@ class HighLevelILBasicBlock(basicblock.BasicBlock):
for idx in range(self.start, self.end):
yield self.il_function[idx]
- def __getitem__(self, idx) -> Union[List[HighLevelILInstruction], HighLevelILInstruction]:
+ @overload
+ def __getitem__(self, idx: int) -> 'HighLevelILInstruction': ...
+
+ @overload
+ def __getitem__(self, idx: slice) -> List['HighLevelILInstruction']: ...
+
+ def __getitem__(self, idx: Union[int, slice]) -> Union[List[HighLevelILInstruction], HighLevelILInstruction]:
size = self.end - self.start
if isinstance(idx, slice):
return [self[index] for index in range(*idx.indices(size))] # type: ignore