Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Adjust lint job
  • Loading branch information
ShaharNaveh committed May 26, 2026
commit f9a754c8d3f3deaac9b88cf8cb168e2daa968d7a
27 changes: 26 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,8 @@ jobs:
security-events: write # for zizmor
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false

- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0

Expand All @@ -544,12 +546,35 @@ jobs:
package-manager-cache: false
node-version: "24"

- name: prek
- name: install prek
id: prek
uses: j178/prek-action@bdca6f102f98e2b4c7029491a53dfd366469e33d # v2.0.4
with:
cache: false
show-verbose-logs: false
install-only: true

- name: prek run
run: prek run --show-diff-on-failure --color=always --all-files

- name: Get target CPython version
id: cpython-version
run: |
version=$(cat .python-version)
echo "version=${version}" >> "$GITHUB_OUTPUT"

- name: Clone CPython
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: python/cpython
path: cpython
ref: "v${{ steps.cpython-version.outputs.version }}"
persist-credentials: false

- name: prek run (manual stage)
run: prek run --show-diff-on-failure --color=always --all-files --hook-stage manual
env:
CPYTHON_ROOT: ${{ github.workspace }}/cpython

- name: save prek cache
if: ${{ github.ref == 'refs/heads/main' }} # only save on main
Expand Down
21 changes: 17 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,27 @@ repos:
types: [rust]
priority: 0

- id: generate-opcode-metadata
name: generate opcode metadata
entry: python scripts/generate_opcode_metadata.py
files: '^(crates/compiler-core/src/bytecode/instruction\.rs|scripts/generate_opcode_metadata\.py)$'
- id: generate-rs-opcode-metadata
name: generate rust opcode metadata
entry: python tools/opcode_metadata/generate_rs_opcode_metadata.py
files: '^(crates/compiler-core/src/bytecode/instruction\.rs|tools/opcode_metadata/*)$'
pass_filenames: false
Comment on lines +46 to 47

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

python - <<'PY'
import re
pat = re.compile(r'^(crates/compiler-core/src/bytecode/instruction\.rs|tools/opcode_metadata/*)$')
samples = [
    "crates/compiler-core/src/bytecode/instruction.rs",
    "tools/opcode_metadata/opcodes.py",
    "tools/opcode_metadata/utils.py",
]
print("Sample matches:")
for s in samples:
    print(f"{s}: {bool(pat.search(s))}")
PY

python - <<'PY'
import re, subprocess
pat = re.compile(r'^(crates/compiler-core/src/bytecode/instruction\.rs|tools/opcode_metadata/*)$')
files = subprocess.check_output(["git", "ls-files"], text=True).splitlines()
matches = [f for f in files if pat.search(f)]
print(f"repo_match_count={len(matches)}")
for f in matches[:20]:
    print(f)
PY

Repository: RustPython/RustPython

Length of output: 282


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show the exact current lines around the two reported occurrences
sed -n '35,70p' .pre-commit-config.yaml | nl -ba | sed -n '30,55p'

python3 - <<'PY'
import re, subprocess
pat = re.compile(r'^(crates/compiler-core/src/bytecode/instruction\.rs|tools/opcode_metadata/*)$')
files = subprocess.check_output(["git", "ls-files"], text=True).splitlines()
matches = [f for f in files if pat.search(f)]
print(f"repo_match_count={len(matches)}")
for f in matches:
    print(f)
PY

python3 - <<'PY'
import re, subprocess
pat = re.compile(r'^(crates/compiler-core/src/bytecode/instruction\.rs|tools/opcode_metadata/.*)$')
files = subprocess.check_output(["git", "ls-files"], text=True).splitlines()
matches = [f for f in files if pat.search(f)]
print(f"repo_match_count_with_fixed_regex={len(matches)}")
for f in matches[:30]:
    print(f)
PY

Repository: RustPython/RustPython

Length of output: 108


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Display relevant section with line numbers (cat -n is widely available)
cat -n .pre-commit-config.yaml | sed -n '35,70p'

python3 - <<'PY'
import re, subprocess
pat = re.compile(r'^(crates/compiler-core/src/bytecode/instruction\.rs|tools/opcode_metadata/*)$')
files = subprocess.check_output(["git", "ls-files"], text=True).splitlines()
matches = [f for f in files if pat.search(f)]
print("repo_match_count=", len(matches))
for f in matches:
    print(f)
PY

python3 - <<'PY'
import re, subprocess
pat = re.compile(r'^(crates/compiler-core/src/bytecode/instruction\.rs|tools/opcode_metadata/.*)$')
files = subprocess.check_output(["git", "ls-files"], text=True).splitlines()
matches = [f for f in files if pat.search(f)]
print("repo_match_count_with_fixed_regex=", len(matches))
for f in matches[:50]:
    print(f)
PY

Repository: RustPython/RustPython

Length of output: 1850


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Display relevant section with line numbers (cat -n is widely available)
cat -n .pre-commit-config.yaml | sed -n '35,70p'

python3 - <<'PY'
import re, subprocess
pat = re.compile(r'^(crates/compiler-core/src/bytecode/instruction\.rs|tools/opcode_metadata/*)$')
files = subprocess.check_output(["git", "ls-files"], text=True).splitlines()
matches = [f for f in files if pat.search(f)]
print("repo_match_count=", len(matches))
for f in matches:
    print(f)
PY

python3 - <<'PY'
import re, subprocess
pat = re.compile(r'^(crates/compiler-core/src/bytecode/instruction\.rs|tools/opcode_metadata/.*)$')
files = subprocess.check_output(["git", "ls-files"], text=True).splitlines()
matches = [f for f in files if pat.search(f)]
print("repo_match_count_with_fixed_regex=", len(matches))
for f in matches[:50]:
    print(f)
PY

Repository: RustPython/RustPython

Length of output: 1850


Fix files regex so opcode-metadata hooks trigger on tools/opcode_metadata/* changes

The current regex tools/opcode_metadata/* doesn’t match real files like tools/opcode_metadata/opcodes.py, so both manual hooks only match crates/compiler-core/src/bytecode/instruction.rs. Update both hook files patterns to tools/opcode_metadata/.*.

💡 Proposed fix
-        files: '^(crates/compiler-core/src/bytecode/instruction\.rs|tools/opcode_metadata/*)$'
+        files: '^(crates/compiler-core/src/bytecode/instruction\.rs|tools/opcode_metadata/.*)$'
...
-        files: '^(crates/compiler-core/src/bytecode/instruction\.rs|tools/opcode_metadata/*)$'
+        files: '^(crates/compiler-core/src/bytecode/instruction\.rs|tools/opcode_metadata/.*)$'
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.pre-commit-config.yaml around lines 46 - 47, The hook `files` regex
currently uses `tools/opcode_metadata/*` which doesn't match files like
`tools/opcode_metadata/opcodes.py`; update both occurrences of the `files`
pattern in the pre-commit config (the lines with `files:` that currently contain
`tools/opcode_metadata/*`) to use `tools/opcode_metadata/.*` so the
opcode-metadata hooks trigger on changes under that directory (keep
`pass_filenames: false` as-is).

language: system
require_serial: true
priority: 1 # so rustfmt runs first
stages:
- manual

- id: generate-py-opcode-metadata
name: generate python opcode metadata
entry: python tools/opcode_metadata/generate_py_opcode_metadata.py
files: '^(crates/compiler-core/src/bytecode/instruction\.rs|tools/opcode_metadata/*)$'
pass_filenames: false
language: system
require_serial: true
priority: 1 # so rustfmt runs first
stages:
- manual

- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v10.0.0
Expand Down
Loading