Commit a9da19c
Guard node.graph.owning_module against None for mypy (pytorch#20792)
### 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
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent ff927c8 commit a9da19c
2 files changed
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
46 | 49 | | |
47 | | - | |
| 50 | + | |
48 | 51 | | |
49 | 52 | | |
50 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
73 | 76 | | |
74 | 77 | | |
75 | 78 | | |
| |||
0 commit comments