From cd25fe8ea91a73a86cf36e1777b91c6311b9ef57 Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Tue, 31 Dec 2024 10:24:07 -0800 Subject: [PATCH] Fix typing pyre fix me issues (#1480) Summary: Pull Request resolved: https://github.com/pytorch/captum/pull/1480 Fix typing fixme issues and switch slice to pyre-ignore, since this is related to earlier Python version limitation Reviewed By: banne01 Differential Revision: D67726226 fbshipit-source-id: d0c923d771d20c03500d91de902f840205568478 --- captum/_utils/typing.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/captum/_utils/typing.py b/captum/_utils/typing.py index 80cf22d45..efa437649 100644 --- a/captum/_utils/typing.py +++ b/captum/_utils/typing.py @@ -21,8 +21,9 @@ TensorOrTupleOfTensorsGeneric = TypeVar( "TensorOrTupleOfTensorsGeneric", Tensor, Tuple[Tensor, ...] ) -# pyre-fixme[24]: Generic type `tuple` expects at least 1 type parameter. -TupleOrTensorOrBoolGeneric = TypeVar("TupleOrTensorOrBoolGeneric", Tuple, Tensor, bool) +TupleOrTensorOrBoolGeneric = TypeVar( + "TupleOrTensorOrBoolGeneric", Tuple[Tensor, ...], Tensor, bool +) ModuleOrModuleList = TypeVar("ModuleOrModuleList", Module, List[Module]) TargetType = Union[None, int, Tuple[int, ...], Tensor, List[Tuple[int, ...]], List[int]] BaselineTupleType = Union[None, Tuple[Union[Tensor, int, float], ...]] @@ -46,7 +47,7 @@ # falling back to slice type. SliceIntType = slice[int, int, int] except TypeError: - # pyre-fixme[24]: Generic type `slice` expects 3 type parameters. + # pyre-ignore[24]: Generic type `slice` expects 3 type parameters. SliceIntType = slice # type: ignore # Necessary for Python >=3.7 and <3.9!