Skip to content

Guard node.graph.owning_module against None for mypy#20792

Merged
rascani merged 1 commit into
pytorch:mainfrom
rascani:fix-mypy-owning-module-optional
Jul 8, 2026
Merged

Guard node.graph.owning_module against None for mypy#20792
rascani merged 1 commit into
pytorch:mainfrom
rascani:fix-mypy-owning-module-optional

Conversation

@rascani

@rascani rascani commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

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

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>
@rascani rascani requested a review from JacobSzwejbka July 8, 2026 17:35
@rascani rascani requested a review from digantdesai as a code owner July 8, 2026 17:35
@pytorch-bot

pytorch-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown

🔗 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 Failure

As of commit 81cbfcf with merge base 3801496 (image):

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

  • pull / android / build-android (gh) (trunk failure)
    ImportError: /opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages/executorch/extension/training/pybindings/_training_lib.cpython-311-x86_64-linux-gnu.so: undefined symbol: _ZN3c104impl3cow23materialize_cow_storageERNS_11StorageImplE

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 8, 2026
@github-actions github-actions Bot added ciflow/trunk module: arm Issues related to arm backend labels Jul 8, 2026
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@rascani rascani merged commit a9da19c into pytorch:main Jul 8, 2026
497 of 503 checks passed
@rascani rascani deleted the fix-mypy-owning-module-optional branch July 8, 2026 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. module: arm Issues related to arm backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants