-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Remove _dis module
#6690
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
Remove _dis module
#6690
Conversation
📝 WalkthroughWalkthroughThis PR systematically renames CodeFlags enum variants to standardize naming conventions, removing prefixes like Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Code has been automatically formatted The code in this PR has been formatted using git pull origin try-update-dis |
4ceacf1 to
ec25472
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
crates/vm/src/builtins/function.rs (3)
127-155: LGTM! Proper validation for excess positional arguments.The rename from
HAS_VARARGStoVARARGSaligns with standard Python CodeFlags naming conventions. The new else branch (lines 131-155) correctly enforces Python semantics by rejecting excess positional arguments when the function doesn't accept*args. The error message properly indicates the valid range of positional arguments and handles grammatical number agreement correctly.
158-164: LGTM! Flag rename aligns with standard conventions.The rename from
HAS_VARKEYWORDStoVARKEYWORDSis consistent with the broader refactoring to align with standard Python CodeFlags naming.
417-423: LGTM! Flag rename aligns with standard conventions.The rename from
NEW_LOCALStoNEWLOCALSis consistent with the standard Python CodeFlags naming, removing the underscore prefix.
🤖 Fix all issues with AI agents
In @crates/vm/src/builtins/function.rs:
- Around line 439-440: No code changes required; the rename from
IS_GENERATOR/IS_COROUTINE to bytecode::CodeFlags::GENERATOR and ::COROUTINE and
the match logic that constructs generator/coroutine/async generator objects are
correct as-is, so leave the uses of
code.flags.contains(bytecode::CodeFlags::GENERATOR) and
code.flags.contains(bytecode::CodeFlags::COROUTINE) and the surrounding
match/creation logic unchanged.
🧹 Nitpick comments (1)
crates/codegen/src/compile.rs (1)
6369-6383: Minor: avoid shadowingflagswhen addingCOROUTINEin comprehensions.This is correct as-is, but the double
let flags = ...; let flags = if ...is a small readability hit.Proposed refactor
- let flags = bytecode::CodeFlags::NEWLOCALS | bytecode::CodeFlags::OPTIMIZED; - let flags = if is_async { - flags | bytecode::CodeFlags::COROUTINE - } else { - flags - }; + let mut flags = bytecode::CodeFlags::NEWLOCALS | bytecode::CodeFlags::OPTIMIZED; + if is_async { + flags |= bytecode::CodeFlags::COROUTINE; + }
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (4)
Lib/dis.pyis excluded by!Lib/**Lib/test/test_dis.pyis excluded by!Lib/**Lib/test/test_inspect/test_inspect.pyis excluded by!Lib/**Lib/test/test_unittest/testmock/testasync.pyis excluded by!Lib/**
📒 Files selected for processing (8)
crates/codegen/src/compile.rscrates/codegen/src/ir.rscrates/compiler-core/src/bytecode.rscrates/stdlib/src/dis.rscrates/stdlib/src/lib.rscrates/vm/src/builtins/function.rscrates/vm/src/builtins/function/jit.rscrates/vm/src/frame.rs
💤 Files with no reviewable changes (2)
- crates/stdlib/src/lib.rs
- crates/stdlib/src/dis.rs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.rs: Follow the default rustfmt code style by runningcargo fmtto format Rust code
Always run clippy to lint code (cargo clippy) before completing tasks and fix any warnings or lints introduced by changes
Follow Rust best practices for error handling and memory management
Use the macro system (pyclass,pymodule,pyfunction, etc.) when implementing Python functionality in Rust
Files:
crates/codegen/src/ir.rscrates/vm/src/builtins/function/jit.rscrates/vm/src/builtins/function.rscrates/vm/src/frame.rscrates/codegen/src/compile.rscrates/compiler-core/src/bytecode.rs
🧬 Code graph analysis (1)
crates/vm/src/builtins/function.rs (1)
crates/vm/src/frame.rs (2)
locals(158-194)locals(2402-2406)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Run snippets and cpython tests (ubuntu-latest)
- GitHub Check: Run snippets and cpython tests (windows-2025)
🔇 Additional comments (16)
crates/compiler-core/src/bytecode.rs (2)
374-379: LGTM! Clean flag naming standardization.The renamed constants remove unnecessary prefixes, improving readability. Bit positions remain unchanged, ensuring binary compatibility.
1554-1561: Flag usage correctly updated.The method properly uses the renamed
VARARGSandVARKEYWORDSflags to determine argument structure.crates/vm/src/builtins/function/jit.rs (1)
73-81: Flag check correctly updated for JIT argument validation.The updated flag names maintain the same logic: preventing JIT compilation of functions with variable argument counts.
crates/codegen/src/ir.rs (1)
335-336: Correct flag usage in cell2arg calculation.The total argument count properly includes variadic arguments using the renamed flags.
crates/vm/src/frame.rs (3)
189-191: Flag usage correctly updated.The
OPTIMIZEDflag check properly controls freevar mapping in the locals collection logic.
1003-1009: Coroutine context check correctly updated.The
COROUTINEflag properly enforces that coroutines can only be yielded from within coroutine contexts.
1674-1678: Async generator wrapping logic correctly updated.The
COROUTINEflag determines whether to wrap yielded values for async generators. The logic is correct: wrap only whenarg == 0(direct yield) and theCOROUTINEflag is set.crates/codegen/src/compile.rs (9)
377-404: Verify moduleCodeFlagsinitialization matches intendedco_flags(NEWLOCALS vs empty).
Compiler::newinitializes the moduleir::CodeInfo.flagsasCodeFlags::NEWLOCALS(Line 380), whileenter_scopeusesCodeFlags::empty()forCompilerScope::Module(Line 749). If standarddis.pycompatibility depends on exactco_flags, please confirm the module-level choice is intentional (and consistent with howCodeObject.co_flagsis computed).
747-769: Scope default flags update looks consistent with the renamedCodeFlags.Function-like scopes default to
NEWLOCALS | OPTIMIZED, while module/class remainempty(). This aligns with usingCOROUTINE/GENERATORas additional markers elsewhere.
1298-1323:make_qualname: usingOPTIMIZEDfor “function parent” detection is reasonable—ensure no non-function scopes set it.
is_function_parentnow keys offparent.flags.contains(CodeFlags::OPTIMIZED)(Line 1301) plus name guards. Please double-check there aren’t any non-function scopes that setOPTIMIZEDwhile having a non-"<...>"name, or they’ll get.<locals>.qualnames unexpectedly.
1911-1919: Async return check updated correctly toCodeFlags::GENERATOR.
2064-2090: Function entry flags + varargs/kwargs flags updated correctly.
push_output(NEWLOCALS | OPTIMIZED, ...)plusVARARGS/VARKEYWORDSmutations look consistent with the rename and prior behavior.
3103-3120: Coroutine flag set viaflags.set(COROUTINE, is_async)is clean and clear.
3233-3241: Type-params scope flags updated consistently.Also applies to: 3664-3672
7042-7044: Generator marking updated correctly toCodeFlags::GENERATOR.
1-20: Please run formatting/lints/tests for the flag rename sweep.Per repo guidelines for
**/*.rs, make surecargo fmtandcargo clippyare clean, and that dis-/opcode-metadata-related tests/snapshots still match expectations after theCodeFlagsrename and_disremoval.
| let is_gen = code.flags.contains(bytecode::CodeFlags::GENERATOR); | ||
| let is_coro = code.flags.contains(bytecode::CodeFlags::COROUTINE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
LGTM! Flag renames align with standard conventions.
The renames from IS_GENERATOR to GENERATOR and IS_COROUTINE to COROUTINE are consistent with standard Python CodeFlags naming, removing the IS_ prefix. The match logic correctly handles all combinations for creating the appropriate generator/coroutine/async generator objects.
🤖 Prompt for AI Agents
In @crates/vm/src/builtins/function.rs around lines 439 - 440, No code changes
required; the rename from IS_GENERATOR/IS_COROUTINE to
bytecode::CodeFlags::GENERATOR and ::COROUTINE and the match logic that
constructs generator/coroutine/async generator objects are correct as-is, so
leave the uses of code.flags.contains(bytecode::CodeFlags::GENERATOR) and
code.flags.contains(bytecode::CodeFlags::COROUTINE) and the surrounding
match/creation logic unchanged.
youknowone
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! This moment came sooner than I expected!
After #6638
Lib/_opcode_metadata.pyis generated for our bytecode, so it might be possible to usedis.pyand not patch it at allSummary by CodeRabbit
Refactor
Chores
✏️ Tip: You can customize this high-level summary in your review settings.