Skip to content

Commit 27ddb9b

Browse files
Vivek Miglanifacebook-github-bot
authored andcommitted
Add pyre-ignore for Future instantiation in common.py and basic_models.py
Summary: Pyre reports `Call error [29]: typing.Type[Future] is not a function` when instantiating `torch.futures.Future()` because the type stubs declare it as a generic type rather than a callable class. Added `pyre-ignore[29]` comments to suppress these false positives since `Future` is callable at runtime. This affects: - `_construct_future_forward` in common.py - `BasicModel_MultiLayer_with_Future.forward` in basic_models.py Differential Revision: D89870780
1 parent 04e90ea commit 27ddb9b

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

captum/_utils/common.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,7 @@ def _format_outputs(
574574
# pyre-fixme[24] Callable requires 2 arguments
575575
def _construct_future_forward(original_forward: Callable) -> Callable:
576576
def future_forward(*args: Any, **kwargs: Any) -> torch.futures.Future[Tensor]:
577+
# pyre-ignore[29]: `Future` is callable at runtime
577578
fut: torch.futures.Future[Tensor] = torch.futures.Future()
578579
fut.set_result(original_forward(*args, **kwargs))
579580
return fut

captum/testing/helpers/basic_models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ def forward(
581581
self.relu(lin1_out)
582582
else:
583583
relu_out = self.relu(lin1_out)
584+
# pyre-ignore[29]: `Future` is callable at runtime
584585
result = Future()
585586
lin2_out = self.linear2(relu_out)
586587
if multidim_output:

0 commit comments

Comments
 (0)