Guard node.graph.owning_module against None for mypy#20792
Conversation
torch 2.13.0 types torch.fx.Graph.owning_module as Optional[GraphModule], which surfaced two latent lintrunner-mypy errors on unchanged code. The lint job installs torch unpinned, so this began failing on trunk once a run resolved a torchvision compatible with torch 2.13.0 (earlier runs were silently downgraded to 2.12.1, masking the errors). Guard owning_module for None (and narrow node.target to str in the arm pass) before use. This also hardens both call sites against a genuinely absent owning module at runtime. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20792
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 1 Unrelated FailureAs of commit 81cbfcf with merge base 3801496 ( NEW FAILURE - The following job has failed:
BROKEN TRUNK - The following job failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
Summary
torch 2.13.0 types torch.fx.Graph.owning_module as Optional[GraphModule], which surfaced two latent lintrunner-mypy errors on unchanged code. The lint job installs torch unpinned, so this began failing on trunk once a run resolved a torchvision compatible with torch 2.13.0 (earlier runs were silently downgraded to 2.12.1, masking the errors).
Guard owning_module for None (and narrow node.target to str in the arm pass) before use. This also hardens both call sites against a genuinely absent owning module at runtime.
cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell