Support compile(module=...) across AST warning paths - #8947
Draft
youknowdot wants to merge 1 commit into
Draft
youknowdot wants to merge 1 commit into
youknowdot wants to merge 1 commit into
Conversation
Add Python 3.15 compile(module=...) warning filtering. Move format-spec diagnostics to a fallible, literal-aware AST boundary; preserve nested literal warnings while excluding raw text and comments, map function-type fragments to source locations, and suppress duplicate type-comment emissions with per-call tracking. Keep unrelated legacy warning-detection and exact diagnostic metadata gaps documented by differential probes. Add focused flag, source-location, exception, reentrancy, filtering and literal-boundary regression coverage. Assisted-by: Codex:model-version-unavailable
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
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 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add Python 3.15's keyword-only
compile(module=...)argument for SyntaxWarning filtering, including AST-only compilation and type comments. This is an independent native prerequisite for the 3.15 importlib/bootstrap migration; the advertised Python version and bundled libraries remain unchanged.moduleas str or None, keep diagnostic filenames separate, and preserve the existing Rust compile APIs through wrappersThe implementation does not run a new whole-source warning scan before every AST parse or keep mutable warning context in VM-global/thread-local state.
Reference: CPython v3.15.0rc2, commit
435c9e5a798c99653e3ab64ce29baed0e4f3dfee. Its importlib source loader supplies this module context when compiling source.Validation
Independent branch at
a86db2711a26ece3781f39fea7b48c042f59bb3f:-m test test_compile test_ast test_warnings test_site test_support test_importlib test_pkgutil --timeout 180: all seven suites successful, 2,156 run and 152 skippedRemaining scope limits
This does not claim full compiler-warning parity. Existing missing warnings for ordinary AST-only literals and some ordinary-source/raw/template paths, and unrelated parser/traversal ordering, remain outside this change.
The shared diagnostic formatter also retains precise differences from CPython: three nested-template error cases point at the actual backslash rather than CPython's shifted position; three function-type cases append a newline to SyntaxError.text; one existing codegen case lacks end fields and differs in source text. These do not change module filtering, exception identity/type, valid-source acceptance, or duplicate suppression. They are recorded rather than hidden behind skips or CPython-specific caret adjustments.
AI assistance
OpenAI Codex assisted with implementation, CPython comparison, tests, review, and this description under maintainer direction. The runtime did not expose the exact model version. Results are automated Linux x86_64 verification; no additional human-use or untested-platform validation is claimed.