Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch python syntax to use Path.parents #4235

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bazel/check_deps/update_roots.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

# Change the working directory to the repository root so that the remaining
# operations reliably operate relative to that root.
os.chdir(Path(__file__).parent.parent.parent)
os.chdir(Path(__file__).parents[2])

print("Compute non-test C++ root targets...")
non_test_cc_roots_query = subprocess.check_output(
Expand Down
2 changes: 1 addition & 1 deletion scripts/run_clang_tidy.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def main() -> None:
files = ["^(?!.*/(bazel-|third_party)).*$"]

# Set the repo root as the working directory.
os.chdir(Path(__file__).resolve().parent.parent)
os.chdir(Path(__file__).parents[1])
# Ensure create_compdb has been run.
subprocess.check_call(["./scripts/create_compdb.py"])

Expand Down
2 changes: 1 addition & 1 deletion scripts/scripts_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def chdir_repo_root() -> None:

This is done so that scripts run from a consistent directory.
"""
os.chdir(Path(__file__).parent.parent)
os.chdir(Path(__file__).parents[1])


def _get_hash(file: Path) -> str:
Expand Down
2 changes: 1 addition & 1 deletion toolchain/autoupdate_testdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def main() -> None:
# Support specifying tests to update, such as:
# ./autoupdate_testdata.py lex/**/*
if len(sys.argv) > 1:
repo_root = Path(__file__).resolve().parent.parent
repo_root = Path(__file__).parents[1]
file_tests = []
# Filter down to just test files.
for f in sys.argv[1:]:
Expand Down
2 changes: 1 addition & 1 deletion toolchain/diagnostics/check_diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def check_unused(decls: Set[str], uses: Dict[str, List[Loc]]) -> bool:

def main() -> None:
# Run from the repo root.
os.chdir(Path(__file__).parent.parent.parent)
os.chdir(Path(__file__).parents[2])
decls = load_diagnostic_kind()
uses = load_diagnostic_uses()

Expand Down
2 changes: 1 addition & 1 deletion toolchain/install/toolchain_tar_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def main() -> None:
# Locate the prefix root from the install marker.
if not args.install_marker.exists():
sys.exit("ERROR: No install marker: " + args.install_marker)
prefix_root_path = args.install_marker.parent.parent.parent
prefix_root_path = args.install_marker.parents[2]

# First check that every file and directory in the tar file exists in our
# prefix root, and build a set of those paths.
Expand Down
2 changes: 1 addition & 1 deletion website/prebuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def label_root_file(

def main() -> None:
# Ensure this runs from the repo root.
os.chdir(Path(__file__).parent.parent)
os.chdir(Path(__file__).parents[1])

# bazel-execroot interferes with jekyll because it's a broken symlink.
Path("bazel-execroot").unlink()
Expand Down
Loading