pytorch/torchgen
Xuehai Pan b6bdb67f82 [BE][Easy] use pathlib.Path instead of dirname / ".." / pardir (#129374)
Changes by apply order:

1. Replace all `".."` and `os.pardir` usage with `os.path.dirname(...)`.
2. Replace nested `os.path.dirname(os.path.dirname(...))` call with `str(Path(...).parent.parent)`.
3. Reorder `.absolute()` ~/ `.resolve()`~ and `.parent`: always resolve the path first.

    `.parent{...}.absolute()` -> `.absolute().parent{...}`

4. Replace chained `.parent x N` with `.parents[${N - 1}]`: the code is easier to read (see 5.)

    `.parent.parent.parent.parent` -> `.parents[3]`

5. ~Replace `.parents[${N - 1}]` with `.parents[${N} - 1]`: the code is easier to read and does not introduce any runtime overhead.~

    ~`.parents[3]` -> `.parents[4 - 1]`~

6. ~Replace `.parents[2 - 1]` with `.parent.parent`: because the code is shorter and easier to read.~

Pull Request resolved: https://github.com/pytorch/pytorch/pull/129374
Approved by: https://github.com/justinchuby, https://github.com/malfet
2024-12-29 17:23:13 +00:00
..
_autoheuristic [BE][Easy] use pathlib.Path instead of dirname / ".." / pardir (#129374) 2024-12-29 17:23:13 +00:00
aoti [ARM][feat]: Add 4 bit dynamic quantization matmuls & KleidiAI Backend (#134124) 2024-12-20 19:32:03 +00:00
api [TorchGen] remove remove_non_owning_ref_types from valuetype_type (#142449) 2024-12-12 00:15:44 +00:00
decompositions Revert "Use absolute path path.resolve() -> path.absolute() (#129409)" 2024-12-26 17:26:06 +00:00
dest [1/N] Apply py39 ruff fixes (#138578) 2024-12-02 21:46:18 +00:00
executorch [TorchGen] remove remove_non_owning_ref_types from valuetype_type (#142449) 2024-12-12 00:15:44 +00:00
fuse
operator_versions Revert "Use absolute path path.resolve() -> path.absolute() (#129409)" 2024-12-26 17:26:06 +00:00
selective_build
shape_functions Revert "Use absolute path path.resolve() -> path.absolute() (#129409)" 2024-12-26 17:26:06 +00:00
static_runtime [BE][CI] bump ruff to 0.8.4 (#143753) 2024-12-24 12:24:10 +00:00
__init__.py
BUCK.oss
BUILD.bazel
build.bzl
code_template.py [1/N] Apply py39 ruff fixes (#138578) 2024-12-02 21:46:18 +00:00
context.py [2/N] Apply py39 ruff fixes (#141938) 2024-12-05 06:26:06 +00:00
gen.py Revert "Use absolute path path.resolve() -> path.absolute() (#129409)" 2024-12-26 17:26:06 +00:00
gen_aoti_c_shim.py Fix unused Python variables outside torch/ and test/ (#136359) 2024-12-11 17:10:23 +00:00
gen_backend_stubs.py [BE][Easy] use pathlib.Path instead of dirname / ".." / pardir (#129374) 2024-12-29 17:23:13 +00:00
gen_executorch.py Revert "Use absolute path path.resolve() -> path.absolute() (#129409)" 2024-12-26 17:26:06 +00:00
gen_functionalization_type.py Fix unused Python variables outside torch/ and test/ (#136359) 2024-12-11 17:10:23 +00:00
gen_lazy_tensor.py [BE][Easy] use pathlib.Path instead of dirname / ".." / pardir (#129374) 2024-12-29 17:23:13 +00:00
gen_schema_utils.py [2/N] Apply py39 ruff fixes (#141938) 2024-12-05 06:26:06 +00:00
gen_vmap_plumbing.py [1/N] Apply py39 ruff fixes (#138578) 2024-12-02 21:46:18 +00:00
local.py [1/N] Apply py39 ruff fixes (#138578) 2024-12-02 21:46:18 +00:00
model.py Remove ConstQuantizerPtr in torchgen (#142375) 2024-12-10 02:37:01 +00:00
native_function_generation.py [aotd] capture rrelu_with_noise noise mutation in compile (#141867) 2024-12-04 12:18:58 +00:00
utils.py [1/N] Apply py39 ruff fixes (#138578) 2024-12-02 21:46:18 +00:00
yaml_utils.py