[Dynamo][Better Engineering] Type annotation for torch/_dynamo/output_graph.py (#159602)

As part of better engineering effort, we would like to improve out type support to improve dev experience in dynamo

This PR adds strict typing support to `torch/_dynamo/output_graph.py`

Running
```
mypy torch/_dynamo/output_graph.py --linecount-report /tmp/coverage_log
```

| -------- | Lines Annotated | Lines Total | % lines covered | Funcs Annotated | Funcs Total | % funcs covered |
| -------- | ------- | -------- | ------- | ------- | ------- | ------- |
| Main  |  2163 | 4792 | 45.14% | 121 | 268 | 45.15% |
| This PR | 4818 | 4818 | 100.00% | 268 | 268 | 100.00% |
| Delta    | +2655 | +26 | +54.84% | +147 | 0 | +54.85% |

Pull Request resolved: https://github.com/pytorch/pytorch/pull/159602
Approved by: https://github.com/Skylion007
This commit is contained in:
Lucas Kabela
2025-08-05 03:50:49 +00:00
committed by PyTorch MergeBot
parent 4fd5fabee9
commit b6c53383fe
3 changed files with 220 additions and 147 deletions

View File

@ -204,7 +204,7 @@ def debug_insert_nops(
graph = OutputGraph(
code_options={},
compiler_fn=None,
root_tx=None,
root_tx=None, # type: ignore[arg-type]
export=False,
export_constraints=None,
frame_state={"_id": 0},