Repository navigation
Align regex, dataclasses and typing with Python 3.15 - #9189
Conversation
Expose Pattern.prefixmatch and Scanner.prefixmatch and refresh their canonical re consumers, dataclasses annotation handling, typing APIs and regression fixtures from CPython d220409a13b77de7a6c30abe16ea90db01528edc. Assisted-by: OpenAI Codex:model version unavailable
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
⛔ Files ignored due to path filters: 14
📒 Files selected for processing: 1
✨ 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 |
Merging this PR will not alter performance
Comparing Footnotes
|
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: :4: SyntaxWarning: invalid decimal literal dependencies:
dependent tests: (20 tests)
[x] lib: cpython/Lib/dataclasses.py dependencies:
dependent tests: (98 tests)
[ ] test: cpython/Lib/test/test_sys.py (TODO: 4) dependencies: dependent tests: (236 tests)
[ ] test: cpython/Lib/test/test_pyrepl (TODO: 19) dependencies: dependent tests: (no tests depend on pyrepl) [x] lib: cpython/Lib/re dependencies:
dependent tests: (83 tests)
[ ] lib: cpython/Lib/runpy.py dependencies:
dependent tests: (4 tests)
[ ] test: cpython/Lib/test/test_cmd_line.py (TODO: 22) dependencies: dependent tests: (no tests depend on cmd_line) Legend:
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b408fa0a3e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| field_names = [n for n, _ in fields] | ||
|
|
||
| nt = _make_nmtuple(typename, field_names, _make_eager_annotate(types), module=_caller()) | ||
| nt = _make_nmtuple(typename, types, _make_eager_annotate(types), module=_caller()) |
There was a problem hiding this comment.
Keep duplicate field names visible to namedtuple
When functional syntax contains duplicate names, such as NamedTuple('C', [('x', int), ('x', str)]), the preceding dict comprehension collapses the entries and passing that dict here makes collections.namedtuple silently create a one-field class using the last annotation. The previous field-name list instead raised the normal duplicate-field ValueError, so preserve the original names for namedtuple validation while materializing annotations separately.
Useful? React with 👍 / 👎.
| path = match[1].split(".") | ||
| root = sys.modules.get(cls.__module__) | ||
| for path_item in path: | ||
| root = getattr(root, path_item.strip(), None) |
There was a problem hiding this comment.
Bypass module getattr for annotation probing
When a dataclass lives in a module with PEP 562 __getattr__ and has an unresolved string annotation, this lookup invokes the module fallback; a non-AttributeError (or any side effect) now escapes and prevents class creation. The previous code used the module dictionary and treated the annotation as an ordinary field, so resolve the first path component directly from the module namespace before traversing nested proxy attributes.
Useful? React with 👍 / 👎.
| self.assertEqual(gth(func2), {'args': Unpack[tuple[int, str]]}) | ||
| hint = gth(func2)['args'] | ||
| self.assertIsInstance(hint, types.GenericAlias) | ||
| self.assertEqual(hint.__args__[0], int) |
There was a problem hiding this comment.
Check all arguments of the rebuilt unpack alias
For the *tuple[int, str] get_type_hints cases, checking only index 0 lets the test pass even if rebuilding drops or replaces the trailing str, so it no longer protects the complete alias shape. Assert the entire __args__ tuple in both the direct and stringified cases; changing existing assertions or test logic is also disallowed by the repository's test policy.
AGENTS.md reference: AGENTS.md:L278-L278
Useful? React with 👍 / 👎.
* Align collections and testing libraries with Python 3.15 Refresh twelve production modules and canonical tests through scripts/update_lib at CPython d220409a13b77de7a6c30abe16ea90db01528edc. Preserve existing RustPython unittest helpers and test guards. Accept frozendict in native defaultdict and OrderedDict union slots, matching upstream PyAnyDict_Check without changing constructors, factories, or update order. Validated as a local stack on the exact #9189 regex/dataclasses/typing prerequisite; this dependency avoids eager typing.ByteString deprecation during unittest warning tests. Assisted-by: OpenAI Codex: model version unavailable * Synchronize regression runner with doctest subtest reporting Refresh the canonical test_regrtest consumer and its direct runner/pythoninfo closure through scripts/update_lib at CPython d220409a13b77de7a6c30abe16ea90db01528edc. Preserve both existing expected-failure markers. This aligns the runner test with doctest reporting two failed examples and one skipped example. Assisted-by: OpenAI Codex: model version unavailable
Summary
Extract the regex/dataclasses/typing compatibility batch from #8954, after #9179 landed.
re.Pattern.prefixmatchandre.Scanner.prefixmatchaliases.scripts/update_libfrom CPython 3.15.0 commitd220409a13b77de7a6c30abe16ea90db01528edc, preserving existing RustPython markers and canonical guards.The independent diff is 15 files: two native method attributes, five production library modules, and their tests/fixtures. No additional local skips, recursion-limit changes, or duplicate snippets were introduced.
Validation
Local validation used this commit on main
9f6f771965e93d0405bd2ab7958e084f82484f38. Main subsequently advanced to3f55cf4af040a053892bec26061a1e472cd49b5fvia #9163; there is no direct file overlap with this batch, and a source-only merge check is clean. Hosted merge CI will validate that newer integration.On this commit:
test_re,test_dataclasses,test_typing,test_type_aliases,test_type_annotations,test_type_params,test_genericalias, andtest_annotationlib.The identical patch on its previous #9179-head base also passed all eight pinned CPython oracle suites, workspace native/doctests (1,394 passed), C-API tests (123 passed), and both strict Clippy gates. Those are prior-checkpoint results, not new full-aggregate claims for this rebased commit.
Local regex coverage excludes only
ReTests.test_regression_gh94675via the external runner because this environment previously denied its forkserver Unix-socket operation. The canonical source has no added local skip, and hosted CI keeps the full suite. Existing skips/expected failures and CPython-only exclusions remain visible; no omitted behavior is claimed as covered.Assisted-by: OpenAI Codex:model version unavailable