diff --git a/MODULE.bazel b/MODULE.bazel index 11683d38a880..b5ef04c47d30 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -112,7 +112,7 @@ bazel_dep(name = "rules_python", version = "1.9.0") python = use_extension("@rules_python//python/extensions:python.bzl", "python") python.toolchain( - python_version = "3.11", + python_version = "3.12", ) use_repo(python, "python_versions") diff --git a/bazel/check_deps/update_roots.py b/bazel/check_deps/update_roots.py index 0bb52a4d39eb..1ae3d661d2bd 100755 --- a/bazel/check_deps/update_roots.py +++ b/bazel/check_deps/update_roots.py @@ -1,4 +1,9 @@ -#!/usr/bin/env python3 +#!/usr/bin/env -S uv run --script + +# /// script +# requires-python = ">=3.12" +# /// + """Update the roots of the Carbon build used for dependency checking. diff --git a/bazel/version/gen_tmpl.py b/bazel/version/gen_tmpl.py index 19880353534b..a6264ced04e6 100755 --- a/bazel/version/gen_tmpl.py +++ b/bazel/version/gen_tmpl.py @@ -1,7 +1,7 @@ #!/usr/bin/env -S uv run --script # /// script -# requires-python = ">=3.11" +# requires-python = ">=3.12" # /// # NOTE: The `uv` shebang and inline metadata above are only used for direct diff --git a/examples/bazel/update_module_to_nightly.py b/examples/bazel/update_module_to_nightly.py index d637492c24de..fd0af2333b14 100755 --- a/examples/bazel/update_module_to_nightly.py +++ b/examples/bazel/update_module_to_nightly.py @@ -1,4 +1,9 @@ -#!/usr/bin/env python3 +#!/usr/bin/env -S uv run --script + +# /// script +# requires-python = ">=3.12" +# /// + """Updates example module file to use the nightly toolchain release. diff --git a/github_tools/MODULE.bazel b/github_tools/MODULE.bazel index 8ccf8ad5bb98..dd4c52a8ea1b 100644 --- a/github_tools/MODULE.bazel +++ b/github_tools/MODULE.bazel @@ -16,7 +16,7 @@ bazel_dep(name = "rules_python", version = "0.27.1") python = use_extension("@rules_python//python/extensions:python.bzl", "python") python.toolchain( - python_version = "3.11", + python_version = "3.12", ) use_repo(python, "python_versions") @@ -24,7 +24,7 @@ use_repo(python, "python_versions") pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip") pip.parse( hub_name = "py_deps", - python_version = "3.11", + python_version = "3.12", requirements_lock = "//:requirements.txt", ) use_repo(pip, "py_deps") diff --git a/github_tools/check_dependent_pr.py b/github_tools/check_dependent_pr.py index 71ee8ecb5b74..6caab69a18c1 100755 --- a/github_tools/check_dependent_pr.py +++ b/github_tools/check_dependent_pr.py @@ -1,7 +1,7 @@ #!/usr/bin/env -S uv run --script # /// script -# requires-python = ">=3.10" +# requires-python = ">=3.12" # dependencies = [ # "gql==2.0.0", # "requests", diff --git a/github_tools/pr_comments.py b/github_tools/pr_comments.py index a2785111101b..0c81150b52b0 100755 --- a/github_tools/pr_comments.py +++ b/github_tools/pr_comments.py @@ -1,4 +1,13 @@ -#!/usr/bin/env python3 +#!/usr/bin/env -S uv run --script + +# /// script +# requires-python = ">=3.12" +# dependencies = [ +# "gql==2.0.0", +# "requests", +# ] +# /// + """Figure out comments on a GitHub PR.""" @@ -14,7 +23,7 @@ import hashlib import importlib.util import os import textwrap -from typing import Any, Callable, Optional +from typing import Any, Callable, Optional, override # Do some extra work to support direct runs. try: @@ -178,6 +187,7 @@ class _PRComment(_Comment): def __lt__(self, other: "_PRComment") -> bool: return self.timestamp < other.timestamp + @override def format(self, long: bool) -> str: return "%s\n%s" % (self.url, super().format(long)) diff --git a/proposals/p000555-operator-precedence/figures.py b/proposals/p000555-operator-precedence/figures.py index ee66b7207797..82baf6c11d5c 100755 --- a/proposals/p000555-operator-precedence/figures.py +++ b/proposals/p000555-operator-precedence/figures.py @@ -1,4 +1,9 @@ -#! /usr/bin/env python +#!/usr/bin/env -S uv run --script + +# /// script +# requires-python = ">=3.12" +# /// + __copyright__ = """ Part of the Carbon Language project, under the Apache License v2.0 with LLVM diff --git a/proposals/scripts/check_proposal_names.py b/proposals/scripts/check_proposal_names.py index f12c0072211a..c6e28e37d7e5 100755 --- a/proposals/scripts/check_proposal_names.py +++ b/proposals/scripts/check_proposal_names.py @@ -1,4 +1,9 @@ -#!/usr/bin/env python3 +#!/usr/bin/env -S uv run --script + +# /// script +# requires-python = ">=3.12" +# /// + """Renames proposal files to match convention.""" diff --git a/proposals/scripts/new_proposal.py b/proposals/scripts/new_proposal.py index 5acc9cf9a4ab..396a21b7df74 100755 --- a/proposals/scripts/new_proposal.py +++ b/proposals/scripts/new_proposal.py @@ -1,7 +1,7 @@ #!/usr/bin/env -S uv run --script # /// script -# requires-python = ">=3.11" +# requires-python = ">=3.12" # /// """Prepares a new proposal file and PR.""" diff --git a/pyproject.toml b/pyproject.toml index a32c90a72d2b..8566f46abf5b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,11 +3,11 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception [project] -requires-python = ">=3.11" +requires-python = ">=3.12" [tool.ruff] line-length = 80 -target-version = "py310" +target-version = "py312" [tool.ruff.lint] select = ["E", "F", "W", "I", "ANN"] diff --git a/scripts/bazel_mod_deps.py b/scripts/bazel_mod_deps.py index 5dec2dfcd9db..515994df249c 100755 --- a/scripts/bazel_mod_deps.py +++ b/scripts/bazel_mod_deps.py @@ -1,7 +1,7 @@ #!/usr/bin/env -S uv run --script # /// script -# requires-python = ">=3.11" +# requires-python = ">=3.12" # /// diff --git a/scripts/bench_runner.py b/scripts/bench_runner.py index e7d3814dee73..60141e791534 100755 --- a/scripts/bench_runner.py +++ b/scripts/bench_runner.py @@ -1,7 +1,7 @@ #!/usr/bin/env -S uv run --script # /// script -# requires-python = ">=3.10" +# requires-python = ">=3.12" # dependencies = [ # "numpy", # "rich", @@ -73,7 +73,7 @@ from collections import defaultdict from dataclasses import dataclass, field from enum import Enum from pathlib import Path -from typing import Optional +from typing import Optional, override import numpy as np # type: ignore import scipy as sp # type: ignore @@ -288,6 +288,7 @@ class DeltaKind(Enum): REGRESSION = "[slower]👎[/slower]" NOISE = "" + @override def __str__(self) -> str: return self.value diff --git a/scripts/calculate_release_shas.py b/scripts/calculate_release_shas.py index 171c3a377ace..a6dcfa245d88 100755 --- a/scripts/calculate_release_shas.py +++ b/scripts/calculate_release_shas.py @@ -1,7 +1,7 @@ #!/usr/bin/env -S uv run --script # /// script -# requires-python = ">=3.11" +# requires-python = ">=3.12" # /// diff --git a/scripts/check_build_graph.py b/scripts/check_build_graph.py index 6e37bd3bf785..d5e9e30f2b47 100755 --- a/scripts/check_build_graph.py +++ b/scripts/check_build_graph.py @@ -1,7 +1,7 @@ #!/usr/bin/env -S uv run --script # /// script -# requires-python = ">=3.11" +# requires-python = ">=3.12" # /// diff --git a/scripts/check_header_guards.py b/scripts/check_header_guards.py index 987304a7e9ff..eb036296c684 100755 --- a/scripts/check_header_guards.py +++ b/scripts/check_header_guards.py @@ -1,7 +1,7 @@ #!/usr/bin/env -S uv run --script # /// script -# requires-python = ">=3.11" +# requires-python = ">=3.12" # /// """Checks for missing or incorrect header guards.""" diff --git a/scripts/check_sha_filenames.py b/scripts/check_sha_filenames.py index 8c36b6b3c7fe..73d823999b08 100755 --- a/scripts/check_sha_filenames.py +++ b/scripts/check_sha_filenames.py @@ -1,7 +1,7 @@ #!/usr/bin/env -S uv run --script # /// script -# requires-python = ">=3.11" +# requires-python = ">=3.12" # /// diff --git a/scripts/create_compdb.py b/scripts/create_compdb.py index 6a0c3abf8351..e938db1281d5 100755 --- a/scripts/create_compdb.py +++ b/scripts/create_compdb.py @@ -1,7 +1,7 @@ #!/usr/bin/env -S uv run --script # /// script -# requires-python = ">=3.11" +# requires-python = ">=3.12" # /// diff --git a/scripts/fix_cc_deps.py b/scripts/fix_cc_deps.py index 107756a32912..23aed858dea6 100755 --- a/scripts/fix_cc_deps.py +++ b/scripts/fix_cc_deps.py @@ -1,7 +1,7 @@ #!/usr/bin/env -S uv run --script # /// script -# requires-python = ">=3.11" +# requires-python = ">=3.12" # /// diff --git a/scripts/forbid_llvm_googletest.py b/scripts/forbid_llvm_googletest.py index a76f4bc3d953..6dc53c3b9993 100755 --- a/scripts/forbid_llvm_googletest.py +++ b/scripts/forbid_llvm_googletest.py @@ -1,7 +1,7 @@ #!/usr/bin/env -S uv run --script # /// script -# requires-python = ">=3.11" +# requires-python = ">=3.12" # /// diff --git a/scripts/query_module_versions.py b/scripts/query_module_versions.py index e04fdcb3db2e..e9037ec87aec 100755 --- a/scripts/query_module_versions.py +++ b/scripts/query_module_versions.py @@ -1,7 +1,7 @@ #!/usr/bin/env -S uv run --script # /// script -# requires-python = ">=3.11" +# requires-python = ">=3.12" # /// diff --git a/scripts/run_bazel.py b/scripts/run_bazel.py index 148ffef14662..fdce58e6999a 100755 --- a/scripts/run_bazel.py +++ b/scripts/run_bazel.py @@ -1,7 +1,7 @@ #!/usr/bin/env -S uv run --script # /// script -# requires-python = ">=3.11" +# requires-python = ">=3.12" # /// diff --git a/scripts/run_bazelisk.py b/scripts/run_bazelisk.py index cb5e78c00e3c..41d1f759ad0f 100755 --- a/scripts/run_bazelisk.py +++ b/scripts/run_bazelisk.py @@ -1,7 +1,7 @@ #!/usr/bin/env -S uv run --script # /// script -# requires-python = ">=3.11" +# requires-python = ">=3.12" # /// diff --git a/scripts/run_buildifier.py b/scripts/run_buildifier.py index 51b068a75371..51400b2baa14 100755 --- a/scripts/run_buildifier.py +++ b/scripts/run_buildifier.py @@ -1,7 +1,7 @@ #!/usr/bin/env -S uv run --script # /// script -# requires-python = ">=3.11" +# requires-python = ">=3.12" # /// diff --git a/scripts/run_buildozer.py b/scripts/run_buildozer.py index 8ffd678502e1..602dfe29eaa8 100755 --- a/scripts/run_buildozer.py +++ b/scripts/run_buildozer.py @@ -1,7 +1,7 @@ #!/usr/bin/env -S uv run --script # /// script -# requires-python = ">=3.11" +# requires-python = ">=3.12" # /// diff --git a/scripts/source_stats.py b/scripts/source_stats.py index 430a70e3fac1..884306592d51 100755 --- a/scripts/source_stats.py +++ b/scripts/source_stats.py @@ -1,7 +1,7 @@ #!/usr/bin/env -S uv run --script # /// script -# requires-python = ">=3.11" +# requires-python = ">=3.12" # /// diff --git a/scripts/target_determinator.py b/scripts/target_determinator.py index 527139b6b7ae..e9ea73b13ab7 100755 --- a/scripts/target_determinator.py +++ b/scripts/target_determinator.py @@ -1,7 +1,7 @@ #!/usr/bin/env -S uv run --script # /// script -# requires-python = ">=3.11" +# requires-python = ">=3.12" # /// diff --git a/scripts/workspace_status.py b/scripts/workspace_status.py index 20fe4609fecc..8b331976f56a 100755 --- a/scripts/workspace_status.py +++ b/scripts/workspace_status.py @@ -1,7 +1,7 @@ #!/usr/bin/env -S uv run --script # /// script -# requires-python = ">=3.11" +# requires-python = ">=3.12" # /// # NOTE: The `uv` shebang and inline metadata above are only used for direct diff --git a/toolchain/autoupdate_testdata.py b/toolchain/autoupdate_testdata.py index 0806be0ecb02..64abdc1f37b8 100755 --- a/toolchain/autoupdate_testdata.py +++ b/toolchain/autoupdate_testdata.py @@ -1,7 +1,7 @@ #!/usr/bin/env -S uv run --script # /// script -# requires-python = ">=3.11" +# requires-python = ">=3.12" # /// """Autoupdates testdata in toolchain.""" diff --git a/toolchain/diagnostics/check_diagnostics.py b/toolchain/diagnostics/check_diagnostics.py index 5e0c41b709f0..c4e74db735b9 100755 --- a/toolchain/diagnostics/check_diagnostics.py +++ b/toolchain/diagnostics/check_diagnostics.py @@ -1,4 +1,9 @@ -#!/usr/bin/env python3 +#!/usr/bin/env -S uv run --script + +# /// script +# requires-python = ">=3.12" +# /// + """Checks diagnostic use. @@ -19,7 +24,7 @@ import re import sys from concurrent import futures from pathlib import Path -from typing import Dict, List, NamedTuple, Set +from typing import Dict, List, NamedTuple, Set, override # Example or test diagnostics, ignored because they're expected to not pass. IGNORED = set( @@ -36,6 +41,7 @@ IGNORED = set( class Loc(NamedTuple): """A location for a diagnostic.""" + @override def __str__(self) -> str: return f"{str(self.path)}:{self.line}" diff --git a/website/prebuild.py b/website/prebuild.py index 5503fa695e86..3feaec98797f 100755 --- a/website/prebuild.py +++ b/website/prebuild.py @@ -1,7 +1,7 @@ #!/usr/bin/env -S uv run --script # /// script -# requires-python = ">=3.11" +# requires-python = ">=3.12" # /// """Updates files in preparation for a jekyll build.