pytorch/torch/utils
Edward Z. Yang b816760a2f More progress on type checking ValueRanges (#118870)
Type checking Python is a pain. Here are my learnings:

* The types for heavily polymorphic code is going to be verbose, no way around it. I originally was hoping I could lean on polymorphism with a bounded TypeVar to compactly write signatures for many of the ValueRanges methods, but I ran into some unworkaroundable mypy bugs. Writing out all the types explicitly and using `@overload` liberally works pretty well, so I think I recommend people do that instead of trying to do fancy things.
* Sympy is missing annotations for assumptions, because they are all metaprogrammed. I don't really relish maintaining a typeshed for sympy, so I wrote a small mypy plugin to add them in.
* GADT style refinement is... just not a good idea in practice. Mypy easily gets confused whether or not a return value from a refined section is allowed for the outer return type. So many of these have been replaced with less informative implementation types and more informative external types via overloads. Hopefully this is good for use sites.

Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/118870
Approved by: https://github.com/Skylion007, https://github.com/albanD
2024-02-05 20:29:25 +00:00
..
_sympy More progress on type checking ValueRanges (#118870) 2024-02-05 20:29:25 +00:00
backcompat
benchmark Enable possibly-undefined error code (#118533) 2024-01-30 21:07:01 +00:00
bottleneck
data Enable possibly-undefined error code (#118533) 2024-01-30 21:07:01 +00:00
hipify [ROCm] Hipify trie re-engineering and adding unit tests (#118433) 2024-02-02 16:04:59 +00:00
jit
model_dump
tensorboard Enable possibly-undefined error code (#118533) 2024-01-30 21:07:01 +00:00
viz [Reference Cycle Detector] Ignore FakeTensor in cycle leak detection (#117116) 2024-01-10 21:33:56 +00:00
__init__.py Swap slots if slots match in swap_tensor (#116128) 2023-12-21 00:43:30 +00:00
_config_module.py Enable local_partial_types (#118467) 2024-01-28 13:38:22 +00:00
_config_typing.pyi Revert "[dynamo] guarded config (#111299)" (#115386) 2023-12-11 19:35:42 +00:00
_content_store.py
_contextlib.py Resolve docstring errors in throughput_benchmark.py, weak.py, _traceback.py, file_baton.py, _contextlib.py, _device.py, cpp_backtrace.py, bundled_inputs.py, run_cpu.py, hooks.py, mobile_optimizer.py, _freeze.py, __init__.py, mkldnn.py, dlpack.py (#113311) 2023-11-15 17:40:04 +00:00
_cpp_extension_versioner.py
_cuda_trace.py
_cxx_pytree.py Use strict to toggle strict options in MYPYSTRICT (#118479) 2024-01-28 19:22:22 +00:00
_device.py Enable local_partial_types (#118467) 2024-01-28 13:38:22 +00:00
_foreach_utils.py
_freeze.py [Codemod][python/main_function] caffe2: (#113357) 2023-11-15 22:17:31 +00:00
_import_utils.py [CI] Install dill in ci (#116214) 2024-01-24 23:42:35 +00:00
_mode_utils.py
_python_dispatch.py [BE]: Update flake8 to v6.1.0 and fix lints (#116591) 2024-01-03 06:04:44 +00:00
_pytree.py [pytree][BE] update treespec is_leaf() access (#116371) 2024-01-27 11:44:57 +00:00
_stats.py
_traceback.py Resolve docstring errors in throughput_benchmark.py, weak.py, _traceback.py, file_baton.py, _contextlib.py, _device.py, cpp_backtrace.py, bundled_inputs.py, run_cpu.py, hooks.py, mobile_optimizer.py, _freeze.py, __init__.py, mkldnn.py, dlpack.py (#113311) 2023-11-15 17:40:04 +00:00
_triton.py [Inductor Intel GPU backend Upstream] Generalize part of Inductor test case (#117513) 2024-01-18 08:26:21 +00:00
_typing_utils.py Re-enable type checking for distributed_c10d.py (#115223) 2023-12-09 11:07:54 +00:00
_zip.py [Codemod][python/main_function] caffe2: (#113357) 2023-11-15 22:17:31 +00:00
backend_registration.py
bundled_inputs.py [BE]: Update flake8 to v6.1.0 and fix lints (#116591) 2024-01-03 06:04:44 +00:00
checkpoint.py Enable possibly-undefined error code (#118533) 2024-01-30 21:07:01 +00:00
collect_env.py [BE]: Update flake8 to v6.1.0 and fix lints (#116591) 2024-01-03 06:04:44 +00:00
cpp_backtrace.py Resolve docstring errors in throughput_benchmark.py, weak.py, _traceback.py, file_baton.py, _contextlib.py, _device.py, cpp_backtrace.py, bundled_inputs.py, run_cpu.py, hooks.py, mobile_optimizer.py, _freeze.py, __init__.py, mkldnn.py, dlpack.py (#113311) 2023-11-15 17:40:04 +00:00
cpp_extension.py Clarify how to get extra link flags when building CUDA/C++ extension (#118743) 2024-02-01 22:35:25 +00:00
deterministic.py
dlpack.py
file_baton.py Resolve docstring errors in throughput_benchmark.py, weak.py, _traceback.py, file_baton.py, _contextlib.py, _device.py, cpp_backtrace.py, bundled_inputs.py, run_cpu.py, hooks.py, mobile_optimizer.py, _freeze.py, __init__.py, mkldnn.py, dlpack.py (#113311) 2023-11-15 17:40:04 +00:00
flop_counter.py [BE]: Update flake8 to v6.1.0 and fix lints (#116591) 2024-01-03 06:04:44 +00:00
hooks.py Fix module pre bw hooks when input doesn't req grad but gradients are changed by the user (#116454) 2023-12-28 18:32:50 +00:00
mkldnn.py [BE]: Update flake8 to v6.1.0 and fix lints (#116591) 2024-01-03 06:04:44 +00:00
mobile_optimizer.py Resolve docstring errors in throughput_benchmark.py, weak.py, _traceback.py, file_baton.py, _contextlib.py, _device.py, cpp_backtrace.py, bundled_inputs.py, run_cpu.py, hooks.py, mobile_optimizer.py, _freeze.py, __init__.py, mkldnn.py, dlpack.py (#113311) 2023-11-15 17:40:04 +00:00
model_zoo.py
show_pickle.py
throughput_benchmark.py Resolve docstring errors in throughput_benchmark.py, weak.py, _traceback.py, file_baton.py, _contextlib.py, _device.py, cpp_backtrace.py, bundled_inputs.py, run_cpu.py, hooks.py, mobile_optimizer.py, _freeze.py, __init__.py, mkldnn.py, dlpack.py (#113311) 2023-11-15 17:40:04 +00:00
weak.py [pytorch][PR] introduce WeakHashRef (#115216) 2023-12-07 17:48:11 +00:00