Skip to content
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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ itertools = "0.14"
libc = "0.2"
log = "0.4"
once_cell = "1"
pklr = "0.4.1"
pklr = "0.4.2"
regex = "1"
semver = "1"
serde = { version = "1", features = ["derive"] }
Expand Down
33 changes: 33 additions & 0 deletions scripts/gen_builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,48 @@ class meta extends Annotation {
"""


# Deprecated aliases. These point at a canonical builtin so loading
# Builtins.pkl never reads a deprecated property — under pklr's lazy
# @Deprecated handling (>= 0.4.2) the warning then fires only when a
# user references e.g. `Builtins.check_byte_order_marker`.
# (alias_name, canonical_name, since, message)
DEPRECATED_ALIASES = [
(
"check_byte_order_marker",
"byte_order_marker",
"1.30.0",
"Use `Builtins.byte_order_marker`",
),
(
"fix_byte_order_marker",
"byte_order_marker",
"1.30.0",
"Use `Builtins.byte_order_marker`",
),
]
Comment thread
cursor[bot] marked this conversation as resolved.


def main():
skip = {alias for alias, _, _, _ in DEPRECATED_ALIASES}

# Generate pkl/Builtins.pkl
with open("pkl/Builtins.pkl", "w", newline="\n") as f:
f.write(HEADER)
for filepath in sorted(glob.glob("pkl/builtins/*.pkl")):
filename = os.path.splitext(os.path.basename(filepath))[0]
identifier = filename.replace("-", "_")
if identifier in skip:
continue
f.write(f'{identifier} = Builtins["builtins/{filename}.pkl"].{identifier}\n')

for alias, canonical, since, message in DEPRECATED_ALIASES:
f.write("\n")
f.write("@Deprecated {\n")
f.write(f' since = "{since}"\n')
f.write(f' message = "{message}"\n')
f.write("}\n")
f.write(f'{alias} = Builtins["builtins/{canonical}.pkl"].{canonical}\n')

# pkl format (exits 11 after formatting, ignore that)
subprocess.run(["pkl", "format", "--write", "pkl/Builtins.pkl"])

Expand Down
4 changes: 2 additions & 2 deletions src/cli/migrate/pre_commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1165,13 +1165,13 @@ impl PreCommit {
"check_executables_have_shebangs",
);
map.insert("check-symlinks", "check_symlinks");
map.insert("check-byte-order-marker", "check_byte_order_marker");
map.insert("check-byte-order-marker", "byte_order_marker");
map.insert("check-added-large-files", "check_added_large_files");
map.insert("check-ast", "python_check_ast");
map.insert("debug-statements", "python_debug_statements");
map.insert("detect-private-key", "detect_private_key");
map.insert("no-commit-to-branch", "no_commit_to_branch");
map.insert("fix-byte-order-marker", "fix_byte_order_marker");
map.insert("fix-byte-order-marker", "byte_order_marker");

map
}
Expand Down
Loading