Use absolute path path.resolve() -> path.absolute() (#129409)

Changes:

1. Always explicit `.absolute()`: `Path(__file__)` -> `Path(__file__).absolute()`
2. Replace `path.resolve()` with `path.absolute()` if the code is resolving the PyTorch repo root directory.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/129409
Approved by: https://github.com/albanD
This commit is contained in:
Xuehai Pan
2024-12-24 02:57:29 +08:00
committed by PyTorch MergeBot
parent 362ecad9bb
commit 135c7db99d
84 changed files with 128 additions and 124 deletions

View File

@ -182,7 +182,7 @@ def check_file(
for match in RESULTS_RE.finditer(proc.stdout.decode()):
# Convert the reported path to an absolute path.
abs_path = str(Path(match["file"]).resolve())
abs_path = str(Path(match["file"]).absolute())
message = LintMessage(
path=abs_path,
name=match["code"],
@ -262,7 +262,7 @@ def main() -> None:
print(json.dumps(err_msg._asdict()), flush=True)
sys.exit(0)
abs_build_dir = Path(args.build_dir).resolve()
abs_build_dir = Path(args.build_dir).absolute()
# Get the absolute path to clang-tidy and use this instead of the relative
# path such as .lintbin/clang-tidy. The problem here is that os.chdir is