pytorch/tools/test
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
..
docstring_linter_testdata Enable ruff's unused variable checking everywhere in pytorch (#136965) 2024-12-22 02:33:11 +00:00
heuristics [BE][Easy] use pathlib.Path instead of dirname / ".." / pardir (#129374) 2024-12-29 17:23:13 +00:00
set_linter_testdata set_linter finds and replaces built-in set in Python code (#138454) 2024-12-04 14:31:24 +00:00
gen_operators_yaml_test.py
gen_oplist_test.py
linter_test_case.py set_linter finds and replaces built-in set in Python code (#138454) 2024-12-04 14:31:24 +00:00
test_cmake.py [3/N] Apply py39 ruff fixes (#142115) 2024-12-11 17:50:10 +00:00
test_codegen.py
test_codegen_model.py
test_create_alerts.py
test_docstring_linter.py docstring_linter finds long classes and functions without docstrings (#140426) 2024-12-08 17:03:57 +00:00
test_executorch_custom_ops.py
test_executorch_gen.py
test_executorch_signatures.py
test_executorch_types.py
test_executorch_unboxing.py
test_gen_backend_stubs.py [BE][Easy] use pathlib.Path instead of dirname / ".." / pardir (#129374) 2024-12-29 17:23:13 +00:00
test_selective_build.py
test_set_linter.py set_linter finds and replaces built-in set in Python code (#138454) 2024-12-04 14:31:24 +00:00
test_test_run.py [BE][Easy] use pathlib.Path instead of dirname / ".." / pardir (#129374) 2024-12-29 17:23:13 +00:00
test_test_selections.py [BE][Easy] use pathlib.Path instead of dirname / ".." / pardir (#129374) 2024-12-29 17:23:13 +00:00
test_upload_stats_lib.py [BE][Easy] use pathlib.Path instead of dirname / ".." / pardir (#129374) 2024-12-29 17:23:13 +00:00
test_upload_test_stats.py
test_utils.py
test_vulkan_codegen.py