FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Autogen opcodes metadata by ShaharNaveh · Pull Request #7983 · RustPython/RustPython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (8) .rs  (6) .toml  (2) .yaml  (2) dotfile  (1) All 5 file types selected
Only manifest files
Deleted files Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
19 changes: 10 additions & 9 deletions .gitattributes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ Lib/venv/scripts/posix/* text eol=lf
#
[attr]generated linguist-generated=true diff=generated

Lib/_opcode_metadata.py generated
Lib/keyword.py generated
Lib/idlelib/help.html generated
Lib/test/certdata/*.pem generated
Lib/test/certdata/*.0 generated
Lib/test/levenshtein_examples.json generated
Lib/test/test_stable_abi_ctypes.py generated
Lib/token.py generated
Lib/_opcode_metadata.py generated
Lib/keyword.py generated
Lib/idlelib/help.html generated
Lib/test/certdata/*.pem generated
Lib/test/certdata/*.0 generated
Lib/test/levenshtein_examples.json generated
Lib/test/test_stable_abi_ctypes.py generated
Lib/token.py generated
crates/compiler-core/src/bytecode/opcode_metadata.rs generated

.github/workflows/*.lock.yml linguist-generated=true merge=ours
.github/workflows/*.lock.yml linguist-generated=true merge=ours
27 changes: 26 additions & 1 deletion .github/workflows/ci.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

⚠️ 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
2 changes: 1 addition & 1 deletion Lib/_opcode_metadata.py

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

Loading
Loading

Back | FazBrowse Home | New Git URL