Skip to content

Commit

Permalink
Add type error suppressions for upcoming upgrade (#1345)
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: #1345

Reviewed By: MaggieMoss

Differential Revision: D62550750

fbshipit-source-id: 6e4fa7f92bb16cb5ab80739d0dd72895a7f4f40d
  • Loading branch information
generatedunixname89002005307016 authored and facebook-github-bot committed Sep 12, 2024
1 parent ecfa677 commit 973a071
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions captum/attr/_core/dataloader_attr.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@ def attribute(
assert len(input_roles) == len(inputs), (
"input_roles must have the same size as the return of the dataloader,",
f"length of input_roles is {len(input_roles)} ",
# pyre-fixme[6]: For 1st argument expected
# `pyre_extensions.ReadOnly[Sized]` but got
# `Optional[typing.Tuple[typing.Any, ...]]`.
f"whereas the length of dataloader return is {len(inputs)}",
)

Expand All @@ -395,6 +398,9 @@ def attribute(
"Baselines must have the same size as the return of the dataloader ",
"that need attribution",
f"length of baseline is {len(baselines)} ",
# pyre-fixme[6]: For 1st argument expected
# `pyre_extensions.ReadOnly[Sized]` but got
# `Optional[typing.Tuple[typing.Any, ...]]`.
f'whereas the length of dataloader return with role "0" is {len(inputs)}',
)

Expand All @@ -413,6 +419,9 @@ def attribute(
"Feature mask must have the same size as the return of the dataloader ",
"that need attribution",
f"length of feature_mask is {len(feature_mask)} ",
# pyre-fixme[6]: For 1st argument expected
# `pyre_extensions.ReadOnly[Sized]` but got
# `Optional[typing.Tuple[typing.Any, ...]]`.
f'whereas the length of dataloader return with role "0" is {len(inputs)}',
)

Expand Down
3 changes: 3 additions & 0 deletions captum/attr/_core/deep_lift.py
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,9 @@ def attribute( # type: ignore
" with more than one example but found: {}."
" If baselines are provided in shape of scalars or with a single"
" baseline example, `DeepLift`"
# pyre-fixme[16]: Item `Callable` of `Union[(...) ->
# TensorOrTupleOfTensorsGeneric, TensorOrTupleOfTensorsGeneric]` has no
# attribute `__getitem__`.
" approach can be used instead.".format(baselines[0])
)

Expand Down
3 changes: 3 additions & 0 deletions captum/attr/_core/gradient_shap.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ def attribute(
# attribute `__getitem__`.
assert isinstance(baselines[0], torch.Tensor), (
"Baselines distribution has to be provided in a form "
# pyre-fixme[16]: Item `Callable` of `Union[(...) ->
# TensorOrTupleOfTensorsGeneric, TensorOrTupleOfTensorsGeneric]` has no
# attribute `__getitem__`.
"of a torch.Tensor {}.".format(baselines[0])
)

Expand Down
2 changes: 2 additions & 0 deletions captum/attr/_core/layer/layer_gradient_shap.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ def attribute(
# TensorOrTupleOfTensorsGeneric]` has no attribute `__getitem__`.
assert isinstance(baselines[0], torch.Tensor), (
"Baselines distribution has to be provided in a form "
# pyre-fixme[16]: Item `Callable` of `Union[(...) -> Any,
# TensorOrTupleOfTensorsGeneric]` has no attribute `__getitem__`.
"of a torch.Tensor {}.".format(baselines[0])
)

Expand Down
4 changes: 4 additions & 0 deletions captum/attr/_utils/attribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def __init__(self, forward_func: Callable) -> None:
self.forward_func = forward_func

# pyre-fixme[24]: Generic type `Callable` expects 2 type parameters.
# pyre-fixme[13]: Attribute `attribute` is never initialized.
attribute: Callable
r"""
This method computes and returns the attribution values for each input tensor.
Expand Down Expand Up @@ -74,6 +75,7 @@ def __init__(self, forward_func: Callable) -> None:
"""

# pyre-fixme[24] Generic type `Callable` expects 2 type parameters.
# pyre-fixme[13]: Attribute `attribute_future` is never initialized.
attribute_future: Callable

r"""
Expand Down Expand Up @@ -126,6 +128,7 @@ def has_convergence_delta(self) -> bool:
return False

# pyre-fixme[24]: Generic type `Callable` expects 2 type parameters.
# pyre-fixme[13]: Attribute `compute_convergence_delta` is never initialized.
compute_convergence_delta: Callable
r"""
The attribution algorithms which derive `Attribution` class and provide
Expand Down Expand Up @@ -504,6 +507,7 @@ def __init__(
InternalAttribution.__init__(self, forward_func, layer, device_ids)

# pyre-fixme[24]: Generic type `Callable` expects 2 type parameters.
# pyre-fixme[13]: Attribute `attribute` is never initialized.
attribute: Callable
r"""
This method computes and returns the neuron attribution values for each
Expand Down
1 change: 1 addition & 0 deletions captum/concept/_core/concept.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def __init__(self, model: Module) -> None:
self.model = model

# pyre-fixme[24]: Generic type `Callable` expects 2 type parameters.
# pyre-fixme[13]: Attribute `interpret` is never initialized.
interpret: Callable
r"""
An abstract interpret method that performs concept-based model interpretability
Expand Down

0 comments on commit 973a071

Please sign in to comment.