5f18f240de
Add initial suppressions for pyrefly ( #164177 )
...
Adds suppressions to pyrefly will typecheck clean: https://github.com/pytorch/pytorch/issues/163283
Test plan:
`python3 scripts/lintrunner.py`
`pyrefly check`
---
Pyrefly check before: https://gist.github.com/maggiemoss/3a0aa0b6cdda0e449cd5743d5fce2c60
After:
```
INFO Checking project configured at `/Users/maggiemoss/python_projects/pytorch/pyrefly.toml`
INFO 0 errors (1,063 ignored)
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/164177
Approved by: https://github.com/Lucaskabela
2025-10-02 20:57:41 +00:00
a43c4c3972
[5/N] Apply ruff UP035 rule ( #164423 )
...
Continued code migration to enable ruff `UP035`. Most changes are about moving `Callable` from `typing` to `from collections.abc`.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/164423
Approved by: https://github.com/ezyang
2025-10-02 07:31:11 +00:00
5cedc5a0ff
[BE][PYFMT] migrate PYFMT for torch/[p-z]*/
to ruff format
( #144552 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/144552
Approved by: https://github.com/ezyang
2025-08-07 00:09:56 +00:00
cec2977ed2
[BE][6/16] fix typos in torch/ ( #156316 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156316
Approved by: https://github.com/albanD
ghstack dependencies: #156313 , #156314 , #156315
2025-06-23 02:57:34 +00:00
3f44fdc03d
Revert "[BE][6/16] fix typos in torch/ ( #156316 )"
...
This reverts commit b210cf1ea56bcd9f937a2805d9e70d8684d25ee4.
Reverted https://github.com/pytorch/pytorch/pull/156316 on behalf of https://github.com/atalman due to export/test_torchbind.py::TestCompileTorchbind::test_compile_error_on_input_aliasing_contents_backend_aot_eager [GH job link](https://github.com/pytorch/pytorch/actions/runs/15804799771/job/44548489912 ) [HUD commit link](c95f7fa874
) ([comment](https://github.com/pytorch/pytorch/pull/156313#issuecomment-2994171213 ))
2025-06-22 12:31:57 +00:00
b210cf1ea5
[BE][6/16] fix typos in torch/ ( #156316 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156316
Approved by: https://github.com/albanD
ghstack dependencies: #156313 , #156314 , #156315
2025-06-22 08:43:33 +00:00
f2cfe8b59f
PEP585 update - mostly toplevels ( #145178 )
...
See #145101 for details.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/145178
Approved by: https://github.com/bobrenjc93
2025-01-22 02:21:14 +00:00
45ef3309e3
[BE] typing for decorators ( #144161 )
...
Summary:
Untyped decorators strip annotations from the decorated items.
- _compile
- _inductor/fx_passes/post_grad
- _inductor/lowering
- _library/custom_ops
- _meta_registrations
- _ops
- _refs/nn/functional
- ao/quantization/quantizer/xnnpack_quantizer_utils
- distributed/_composable/contract
- fx/experimental/graph_gradual_typechecker
- fx/experimental/migrate_gradual_types/constraint_generator
- optim/optimizer
- signal/windows/windows
- testing/_internal/common_device_type
- torch/_inductor/decomposition
- utils/flop_counter
Test Plan: unit tests
Differential Revision: D62302684
Pull Request resolved: https://github.com/pytorch/pytorch/pull/144161
Approved by: https://github.com/Skylion007 , https://github.com/albanD
2025-01-04 16:40:09 +00:00
5c4545f857
[BE][Easy] enable PYFMT for torch/[a-s]*/
( #138447 )
...
Reproduce command:
```bash
ghstack checkout https://github.com/pytorch/pytorch/pull/138447
git checkout HEAD~1 torch/
lintrunner -a --take "PYFMT" --all-files
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/138447
Approved by: https://github.com/ezyang
2024-12-23 14:04:00 +00:00
79b7fff188
Fix docstring for torch.signal.windows.nuttall ( #134512 )
...
This partially fixes regression introduced by https://github.com/pytorch/pytorch/pull/124771 but also just improves `z_n` rendering, by using MathML
In 2.3 it was [rendered](https://pytorch.org/docs/2.3/generated/torch.signal.windows.nuttall.html#torch.signal.windows.nuttall )
as
<img width="177" alt="image" src="https://github.com/user-attachments/assets/2c15d1f9-13ad-483f-bb66-41fa3fa4ba9c ">
With this change it'll be [rendered](https://docs-preview.pytorch.org/pytorch/pytorch/134512/generated/torch.signal.windows.nuttall.html#torch.signal.windows.nuttall ) as
```math
z_n = \frac{2 \pi n}{M}
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/134512
Approved by: https://github.com/kit1980 , https://github.com/aorenste , https://github.com/atalman
2024-08-26 22:51:43 +00:00
e448f32944
Revert "[BE] typing for decorators - signal/windows/windows ( #131582 )"
...
This reverts commit 8689d377f9b60b70efa6608e654a3889f947f4d8.
Reverted https://github.com/pytorch/pytorch/pull/131582 on behalf of https://github.com/clee2000 due to breaking lint internally D60265575 ([comment](https://github.com/pytorch/pytorch/pull/131572#issuecomment-2254328359 ))
2024-07-28 03:29:31 +00:00
8689d377f9
[BE] typing for decorators - signal/windows/windows ( #131582 )
...
See #131429
Pull Request resolved: https://github.com/pytorch/pytorch/pull/131582
Approved by: https://github.com/oulgen , https://github.com/zou3519
ghstack dependencies: #131568 , #131569 , #131570 , #131571 , #131572 , #131573 , #131574 , #131575 , #131576 , #131577 , #131578 , #131579 , #131580 , #131581
2024-07-26 05:00:07 +00:00
5a0068cc69
[BE] mypy: disallow untyped decorators ( #131428 )
...
Untyped decorators strip the types from their decorated function so even if the underlying function is fully typed then callers to it don't get any benefit from type annotations.
Step 1 - Enable the error and override in all the offending files.
#131429
Pull Request resolved: https://github.com/pytorch/pytorch/pull/131428
Approved by: https://github.com/justinchuby , https://github.com/oulgen
2024-07-23 21:50:55 +00:00
8db9dfa2d7
Flip default value for mypy disallow_untyped_defs [9/11] ( #127846 )
...
See #127836 for details.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/127846
Approved by: https://github.com/ezyang
ghstack dependencies: #127842 , #127843 , #127844 , #127845
2024-06-08 18:50:06 +00:00
a8574a9719
Fix global flake8 issues ( #124771 )
...
Prior to this `lintrunner --all-files --take FLAKE8` failed.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/124771
Approved by: https://github.com/Skylion007
ghstack dependencies: #124428
2024-04-26 15:35:53 +00:00
1ac60484c1
Revert "Fix global flake8 issues ( #124771 )"
...
This reverts commit f01275934bfa1ff358b1c01d3754f2807cd04ee2.
Reverted https://github.com/pytorch/pytorch/pull/124771 on behalf of https://github.com/jeanschmidt due to Unfortunately, I needed to revert #123735 and this one depends on it. So please check if there are no merge conflicts or breakages and feel free to merge this PR again ([comment](https://github.com/pytorch/pytorch/pull/124428#issuecomment-2078699836 ))
2024-04-26 06:15:17 +00:00
f01275934b
Fix global flake8 issues ( #124771 )
...
Prior to this `lintrunner --all-files --take FLAKE8` failed.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/124771
Approved by: https://github.com/Skylion007
ghstack dependencies: #124428
2024-04-25 14:25:00 +00:00
fa071a2e1b
Clarifying windows cosine behaviour in the documentation ( #119444 )
...
After following the discussion, I've created a PR to update the documentation clarifying the function's behaviour (@tqbl solution 1).
Fixes #110541
Pull Request resolved: https://github.com/pytorch/pytorch/pull/119444
Approved by: https://github.com/malfet
2024-02-09 05:57:44 +00:00
534c73d478
Fix NaN bug in torch.signal.windows.kaiser ( #116470 )
...
Fixes #115595
As an aside, there are currently no tests checking the output of `torch.signal.windows.kaiser` against the output of scipy's implementation, which is what is done with `torch.kaiser_window`. The same goes for the other window functions in `torch.signal.windows`. I did some tests on my end, but I'm not sure what the best practice is, so I haven't included them for now.
@gchanan @mruberry
Pull Request resolved: https://github.com/pytorch/pytorch/pull/116470
Approved by: https://github.com/ezyang
2024-01-08 22:24:52 +00:00
3721fa5612
[BE] Enable ruff's UP rules and autoformat optim/ ( #105426 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/105426
Approved by: https://github.com/malfet , https://github.com/albanD , https://github.com/aaronenyeshi , https://github.com/janeyx99
2023-07-18 21:07:43 +00:00
5837e95d30
[Reland] Update mypy to 1.4.1 ( #105227 )
...
This PR re-lands
- [Typing] Fix PEP 484 Violation (#105022 )
- Update mypy to 1.4.1 (#91983 )
That were reverted due to the conflict with internal source repo.
Mostly fixes for PEP-484 violation (i.e. when default arg is set to None, but type is not annotated as optional)
Plus few real fixes:
- Add missing `_get_upgraders_entry_map` to `torch/_C/__init__.pyi`
- Add missing return statement to `torch._export. deserialize_graph`
- Fix error message in `torch.ao.ns.fx.weight_utils.get_lstm_mod_weights`
- Add assert it `torch/optim/optimizer.py` that Optional list is not None
TODO (in followup PR):
- Fix erroneous `isinstance` check in `torch/ao/quantization/_pt2e/qat_utils.py`
Unrelated, to bypass CI failures due to the gcc9 dependency update in Ubuntu-18.04:
- Add hack to squash older libstdc++ from conda environment in favor one from OS to `.ci/docker/install_conda.sh`
- Update bazel cuda builds to focal, as with libstdc++-6.0.32 bazel builds loose the ability to catch exceptions (probably because they link with cupti statically, but I could not found where it is done)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/105227
Approved by: https://github.com/atalman , https://github.com/albanD , https://github.com/Skylion007
2023-07-15 20:30:20 +00:00
15fd1ea118
Revert "[Reland] Update mypy to 1.4.1 ( #105227 )"
...
This reverts commit c9c4f8efc3dd4e66059522bf5f5c1ba0431e2069.
Reverted https://github.com/pytorch/pytorch/pull/105227 on behalf of https://github.com/atalman due to trying to mitigate ci sev #105248 ([comment](https://github.com/pytorch/pytorch/pull/105227#issuecomment-1636510935 ))
2023-07-14 22:28:35 +00:00
c9c4f8efc3
[Reland] Update mypy to 1.4.1 ( #105227 )
...
This PR re-lands
- [Typing] Fix PEP 484 Violation (#105022 )
- Update mypy to 1.4.1 (#91983 )
That were reverted due to the conflict with internal source repo.
Mostly fixes for PEP-484 violation (i.e. when default arg is set to None, but type is not annotated as optional)
Plus few real fixes:
- Add missing `_get_upgraders_entry_map` to `torch/_C/__init__.pyi`
- Add missing return statement to `torch._export. deserialize_graph`
- Fix error message in `torch.ao.ns.fx.weight_utils.get_lstm_mod_weights`
- Add assert it `torch/optim/optimizer.py` that Optional list is not None
TODO (in followup PR):
- Fix erroneous `isinstance` check in `torch/ao/quantization/_pt2e/qat_utils.py`
Pull Request resolved: https://github.com/pytorch/pytorch/pull/105227
Approved by: https://github.com/atalman , https://github.com/albanD , https://github.com/Skylion007
2023-07-14 20:45:12 +00:00
b4d91b1c5b
Revert "[Typing] Fix PEP 484 Violation ( #105022 )"
...
This reverts commit 4148b7badacace65b8d6309f3f364569c2b0e6a4.
Reverted https://github.com/pytorch/pytorch/pull/105022 on behalf of https://github.com/facebook-github-bot due to Diff reverted internally ([comment](https://github.com/pytorch/pytorch/pull/105022#issuecomment-1635967734 ))
2023-07-14 14:45:09 +00:00
4148b7bada
[Typing] Fix PEP 484 Violation ( #105022 )
...
Not sure, how it worked before, but if arguments must be annotated is optional if they are defaulted to None
Towards enabling mypy-1.4.1 in lintrunner
<!--
copilot:poem
-->
### <samp>🤖 Generated by Copilot at 5e1b9f4</samp>
> _We annotate the arguments of doom_
> _To show the `None` values of gloom_
> _We improve the type checking and readability_
> _With `Optional` annotations of metal-ity_
Pull Request resolved: https://github.com/pytorch/pytorch/pull/105022
Approved by: https://github.com/izaitsevfb , https://github.com/huydhn , https://github.com/Skylion007
2023-07-12 10:20:48 +00:00
79c9e82e27
Fix flake8 lint errors reported by ruff - take 2 ( #99798 )
...
Replaces #99784 . This PR is pure autofix.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/99798
Approved by: https://github.com/Skylion007 , https://github.com/kit1980
2023-04-23 23:09:51 +00:00
333540a458
Reland "Add torch.utils.device_mode" ( #91796 )
...
Original PR https://github.com/pytorch/pytorch/pull/91525
Signed-off-by: Edward Z. Yang <ezyangfb.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/91796
Approved by: https://github.com/albanD
2023-01-09 20:57:12 +00:00
9b415240d4
Revert "Reland "Add torch.utils.device_mode" ( #91796 )"
...
This reverts commit 81b5eff3c383f5308416e129861a2689d717702c.
Reverted https://github.com/pytorch/pytorch/pull/91796 on behalf of https://github.com/huydhn due to This breaks trunk with the following failed test https://hud.pytorch.org/failure/test_jit_save%2CTestTracer
2023-01-09 04:45:47 +00:00
81b5eff3c3
Reland "Add torch.utils.device_mode" ( #91796 )
...
Original PR https://github.com/pytorch/pytorch/pull/91525
Signed-off-by: Edward Z. Yang <ezyangfb.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/91796
Approved by: https://github.com/albanD
2023-01-08 03:44:56 +00:00
f571ae4fdb
Revert "Make torch.device usable as a context manager ( #91525 )"
...
This reverts commit 619d52a5d296bc236ac98f40c7f7de54ab7c9d37.
Reverted https://github.com/pytorch/pytorch/pull/91525 on behalf of https://github.com/mehtanirav due to Internal breakages
2023-01-05 21:34:50 +00:00
619d52a5d2
Make torch.device usable as a context manager ( #91525 )
...
Fixes https://github.com/pytorch/pytorch/issues/82296
Fixes https://github.com/pytorch/pytorch/issues/27878
Fixes https://github.com/pytorch/pytorch/issues/260
Signed-off-by: Edward Z. Yang <ezyang@fb.com >
Pull Request resolved: https://github.com/pytorch/pytorch/pull/91525
Approved by: https://github.com/albanD
2023-01-04 01:32:00 +00:00
ddf5b68dcb
Nuttall window ( #90103 )
...
Relates #85366
Pull Request resolved: https://github.com/pytorch/pytorch/pull/90103
Approved by: https://github.com/lezcano
2022-12-16 09:05:53 +00:00
abb446af8c
Implement old windows in Python ( #87082 )
...
Relates to #85366
- Bartlett, Blackman, Hamming, Hann.
- Except Kaiser which will be in a different PR
Pull Request resolved: https://github.com/pytorch/pytorch/pull/87082
Approved by: https://github.com/mruberry , https://github.com/lezcano
2022-11-25 11:09:28 +00:00
46b16977d9
Reimplement Kaiser window ( #87330 )
...
Relates to #85366
- For reference follow #87082 .
Pull Request resolved: https://github.com/pytorch/pytorch/pull/87330
Approved by: https://github.com/lezcano , https://github.com/mruberry
2022-10-27 21:01:01 +00:00
b48deedb77
Set up new module torch.signal.windows ( #85599 )
...
Resolves #85366
Pull Request resolved: https://github.com/pytorch/pytorch/pull/85599
Approved by: https://github.com/lezcano , https://github.com/mruberry
2022-10-14 11:33:32 +00:00