From 72cb4b08ac8f7c9261867cd6c0b18c054d73b96e Mon Sep 17 00:00:00 2001 From: Josh Ferrell Date: Sun, 21 Apr 2024 22:05:45 -0400 Subject: Improve type hints for many __getitem__ impls --- python/binaryview.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'python/binaryview.py') diff --git a/python/binaryview.py b/python/binaryview.py index 4a160983..d740ce92 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -30,7 +30,7 @@ import inspect import os import uuid from typing import Callable, Generator, Optional, Union, Tuple, List, Mapping, Any, \ - Iterator, Iterable, KeysView, ItemsView, ValuesView, Dict + Iterator, Iterable, KeysView, ItemsView, ValuesView, Dict, overload from dataclasses import dataclass from enum import IntFlag @@ -1985,6 +1985,12 @@ class FunctionList: self._n += 1 return _function.Function(self._view, func) + @overload + def __getitem__(self, i: int) -> '_function.Function': ... + + @overload + def __getitem__(self, i: slice) -> List['_function.Function']: ... + def __getitem__(self, i: Union[int, slice]) -> Union['_function.Function', List['_function.Function']]: if isinstance(i, int): if i < 0: -- cgit v1.3.1