Skip to content

Commit 65ee239

Browse files
craymichaelfacebook-github-bot
authored andcommitted
Clean up pyre lines not suppressing any errors (#1620)
Summary: Pull Request resolved: #1620 As title. Looks like `Any` is OK now...thank goodness Reviewed By: sarahtranfb Differential Revision: D77395444 fbshipit-source-id: 87b5d3373b8a6cd7170d9506d43ee16865e6b4c0
1 parent 8597084 commit 65ee239

32 files changed

+0
-132
lines changed

captum/_utils/av.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,6 @@ def _compute_and_save_activations(
400400
AV.save(path, model_id, identifier, unsaved_layers, new_activations, num_id)
401401

402402
@staticmethod
403-
# pyre-fixme[3]: Return annotation cannot be `Any`.
404-
# pyre-fixme[2]: Parameter annotation cannot be `Any`.
405403
def _unpack_data(data: Union[Any, Tuple[Any, Any]]) -> Any:
406404
r"""
407405
Helper to extract input from labels when getting items from a Dataset. Assumes

captum/_utils/common.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,6 @@ def _format_tensor_into_tuples(
251251
return inputs
252252

253253

254-
# pyre-fixme[3]: Return annotation cannot be `Any`.
255-
# pyre-fixme[2]: Parameter annotation cannot be `Any`.
256254
def _format_inputs(inputs: Any, unpack_inputs: bool = True) -> Any:
257255
return (
258256
inputs
@@ -569,7 +567,6 @@ def future_forward(*args: Any, **kwargs: Any):
569567
def _run_forward(
570568
# pyre-fixme[24]: Generic type `Callable` expects 2 type parameters.
571569
forward_func: Callable,
572-
# pyre-fixme[2]: Parameter annotation cannot be `Any`.
573570
inputs: Any,
574571
target: TargetType = None,
575572
additional_forward_args: Optional[object] = None,
@@ -754,7 +751,6 @@ def _extract_device(
754751

755752
def _reduce_list(
756753
val_list: Sequence[TupleOrTensorOrBoolGeneric],
757-
# pyre-fixme[2]: Parameter annotation cannot contain `Any`.
758754
# pyre-fixme[24]: Generic type `list` expects 1 type parameter, use
759755
# `typing.List[<element type>]` to avoid runtime subscripting errors.
760756
red_func: Callable[[List], Any] = torch.cat,
@@ -832,7 +828,6 @@ def _flatten_tensor_or_tuple(inp: TensorOrTupleOfTensorsGeneric) -> Tensor:
832828
return torch.cat([single_inp.flatten() for single_inp in inp])
833829

834830

835-
# pyre-fixme[3]: Return annotation cannot be `Any`.
836831
def _get_module_from_name(model: Module, layer_name: str) -> Any:
837832
r"""
838833
Returns the module (layer) object, given its (string) name

captum/_utils/gradient.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ def _forward_layer_eval(
227227
def _forward_layer_distributed_eval(
228228
# pyre-fixme[24]: Generic type `Callable` expects 2 type parameters.
229229
forward_fn: Callable,
230-
# pyre-fixme[2]: Parameter annotation cannot be `Any`.
231230
inputs: Any,
232231
layer: ModuleOrModuleList,
233232
target_ind: TargetType = None,
@@ -399,10 +398,8 @@ def _extract_device_ids(
399398
):
400399
if (
401400
hasattr(forward_fn, "device_ids")
402-
# pyre-fixme[33]: Given annotation cannot be `Any`.
403401
and cast(Any, forward_fn).device_ids is not None
404402
):
405-
# pyre-fixme[33]: Given annotation cannot be `Any`.
406403
device_ids = cast(Any, forward_fn).device_ids
407404
else:
408405
raise AssertionError(
@@ -820,7 +817,6 @@ def _extract_parameters_from_layers(layer_modules):
820817

821818
def _compute_jacobian_wrt_params(
822819
model: Module,
823-
# pyre-fixme[2]: Parameter annotation cannot contain `Any`.
824820
inputs: Tuple[Any, ...],
825821
labels: Optional[Tensor] = None,
826822
# pyre-fixme[24]: Generic type `Callable` expects 2 type parameters.
@@ -893,10 +889,8 @@ def _compute_jacobian_wrt_params(
893889
return tuple(grads)
894890

895891

896-
# pyre-fixme[3]: Return annotation cannot contain `Any`.
897892
def _compute_jacobian_wrt_params_with_sample_wise_trick(
898893
model: Module,
899-
# pyre-fixme[2]: Parameter annotation cannot contain `Any`.
900894
inputs: Tuple[Any, ...],
901895
labels: Optional[Tensor] = None,
902896
# pyre-fixme[24]: Generic type `Callable` expects 2 type parameters.

captum/attr/_utils/baselines.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class ProductBaselines:
2222

2323
def __init__(
2424
self,
25-
# pyre-fixme[2]: Parameter annotation cannot contain `Any`.
2625
baseline_values: Union[
2726
List[List[Any]],
2827
Dict[Union[str, Tuple[str, ...]], List[Any]],
@@ -38,7 +37,6 @@ def __init__(
3837
self.dict_keys = dict_keys
3938
self.baseline_values = baseline_values
4039

41-
# pyre-fixme[3]: Return annotation cannot contain `Any`.
4240
def sample(self) -> Union[List[Any], Dict[str, Any]]:
4341
baselines = [
4442
random.choice(baseline_list) for baseline_list in self.baseline_values
@@ -57,7 +55,6 @@ def sample(self) -> Union[List[Any], Dict[str, Any]]:
5755

5856
return dict_baselines
5957

60-
# pyre-fixme[3]: Return annotation cannot contain `Any`.
6158
def __call__(self) -> Union[List[Any], Dict[str, Any]]:
6259
"""
6360
Returns:

captum/attr/_utils/batching.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ def _tuple_splice_range(
136136
)
137137

138138

139-
# pyre-fixme[3]: Return annotation cannot contain `Any`.
140139
def _batched_generator(
141140
inputs: TensorOrTupleOfTensorsGeneric,
142141
additional_forward_args: Optional[object] = None,
@@ -221,8 +220,6 @@ def _batched_operator(
221220
return _reduce_list(all_outputs)
222221

223222

224-
# pyre-fixme[3]: Return annotation cannot be `Any`.
225-
# pyre-fixme[2]: Parameter annotation cannot be `Any`.
226223
def _select_example(curr_arg: Any, index: int, bsz: int) -> Any:
227224
if curr_arg is None:
228225
return None

captum/attr/_utils/class_summarizer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ def update( # type: ignore
6060

6161
num_labels = 1
6262

63-
# pyre-fixme[33]: Given annotation cannot contain `Any`.
6463
labels_typed: Union[List[Any], Tensor]
6564
if isinstance(labels, list) or isinstance(labels, Tensor):
6665
labels_typed = labels

captum/concept/_core/tcav.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,6 @@ def __init__(
315315
self.model_id = model_id
316316
self.concepts: Set[Concept] = set()
317317
self.classifier = classifier
318-
# pyre-fixme[4]: Attribute `classifier_kwargs` of class `TCAV`
319-
# must have a type other than `Any`.
320318
self.classifier_kwargs: Any = classifier_kwargs
321319
# pyre-fixme[8]: Attribute has type `Dict[str, Dict[str, CAV]]`; used as
322320
# `DefaultDict[Variable[_KT], DefaultDict[Variable[_KT], Variable[_VT]]]`.
@@ -740,7 +738,6 @@ def interpret(
740738
classes = []
741739
for concepts in experimental_sets:
742740
concepts_key = concepts_to_str(concepts)
743-
# pyre-fixme[33]: Given annotation cannot contain `Any`.
744741
cavs_stats = cast(Dict[str, Any], self.cavs[concepts_key][layer].stats)
745742
cavs.append(cavs_stats["weights"].float().detach().tolist())
746743
classes.append(cavs_stats["classes"])

captum/influence/_core/influence.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ def __init_(self, model: Module, train_dataset: Dataset, **kwargs: Any) -> None:
3131
self.train_dataset = train_dataset
3232

3333
@abstractmethod
34-
# pyre-fixme[3]: Return annotation cannot be `Any`.
35-
# pyre-fixme[2]: Parameter annotation cannot be `Any`.
3634
def influence(self, inputs: Any = None, **kwargs: Any) -> Any:
3735
r"""
3836
Args:

captum/influence/_core/influence_function.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ def __init__(
263263
@abstractmethod
264264
def self_influence(
265265
self,
266-
# pyre-fixme[2]: Parameter annotation cannot contain `Any`.
267266
inputs_dataset: Optional[Union[Tuple[Any, ...], DataLoader]] = None,
268267
show_progress: bool = False,
269268
) -> Tensor:
@@ -315,7 +314,6 @@ def self_influence(
315314
@abstractmethod
316315
def _get_k_most_influential(
317316
self,
318-
# pyre-fixme[2]: Parameter annotation cannot contain `Any`.
319317
inputs: Union[Tuple[Any, ...], DataLoader],
320318
k: int = 5,
321319
proponents: bool = True,
@@ -367,7 +365,6 @@ def _get_k_most_influential(
367365
@abstractmethod
368366
def _influence(
369367
self,
370-
# pyre-fixme[2]: Parameter annotation cannot contain `Any`.
371368
inputs: Union[Tuple[Any, ...], DataLoader],
372369
show_progress: bool = False,
373370
) -> Tensor:
@@ -486,7 +483,6 @@ class IntermediateQuantitiesInfluenceFunction(InfluenceFunctionBase):
486483
# pyre-fixme[3]: Return type must be annotated.
487484
def compute_intermediate_quantities(
488485
self,
489-
# pyre-fixme[2]: Parameter annotation cannot contain `Any`.
490486
inputs_dataset: Union[Tuple[Any, ...], DataLoader],
491487
aggregate: bool = False,
492488
show_progress: bool = False,
@@ -961,7 +957,6 @@ def _retrieve_projections_naive_influence_function(
961957

962958
def compute_intermediate_quantities(
963959
self,
964-
# pyre-fixme[2]: Parameter annotation cannot contain `Any`.
965960
inputs_dataset: Union[Tuple[Any, ...], DataLoader],
966961
aggregate: bool = False,
967962
show_progress: bool = False,
@@ -1172,7 +1167,6 @@ def influence( # type: ignore[override]
11721167

11731168
def _get_k_most_influential(
11741169
self,
1175-
# pyre-fixme[2]: Parameter annotation cannot contain `Any`.
11761170
inputs: Union[Tuple[Any, ...], DataLoader],
11771171
k: int = 5,
11781172
proponents: bool = True,
@@ -1246,7 +1240,6 @@ def _get_k_most_influential(
12461240

12471241
def _influence(
12481242
self,
1249-
# pyre-fixme[2]: Parameter annotation cannot contain `Any`.
12501243
inputs: Union[Tuple[Any, ...], DataLoader],
12511244
show_progress: bool = False,
12521245
) -> Tensor:
@@ -1287,7 +1280,6 @@ def _influence(
12871280
@log_usage(part_of_slo=True, skip_self_logging=True)
12881281
def self_influence(
12891282
self,
1290-
# pyre-fixme[2]: Parameter annotation cannot contain `Any`.
12911283
inputs_dataset: Optional[Union[Tuple[Any, ...], DataLoader]] = None,
12921284
show_progress: bool = False,
12931285
) -> Tensor:
@@ -1333,7 +1325,6 @@ def self_influence(
13331325

13341326
def _basic_computation_naive_influence_function(
13351327
influence_inst: InfluenceFunctionBase,
1336-
# pyre-fixme[2]: Parameter annotation cannot contain `Any`.
13371328
inputs: Tuple[Any, ...],
13381329
targets: Optional[Tensor] = None,
13391330
# pyre-fixme[24]: Generic type `Callable` expects 2 type parameters.

captum/influence/_core/similarity_influence.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ def influence( # type: ignore[override]
163163
self,
164164
inputs: Union[Tensor, Tuple[Tensor, ...]],
165165
top_k: int = 1,
166-
# pyre-fixme[2]: Parameter annotation cannot be `Any`.
167166
additional_forward_args: Optional[Any] = None,
168167
load_src_from_disk: bool = True,
169168
**kwargs: Any,

0 commit comments

Comments
 (0)