Skip to content

Update test_structseq.py to 3.14.5#7951

Open
ShaharNaveh wants to merge 5 commits into
RustPython:mainfrom
ShaharNaveh:update-test-structseq
Open

Update test_structseq.py to 3.14.5#7951
ShaharNaveh wants to merge 5 commits into
RustPython:mainfrom
ShaharNaveh:update-test-structseq

Conversation

@ShaharNaveh
Copy link
Copy Markdown
Contributor

@ShaharNaveh ShaharNaveh commented May 21, 2026

Summary by CodeRabbit

  • Refactor
    • Internal code generation improvements for macro handling to enhance code consistency and maintainability without affecting functionality.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: fa940411-78f7-4296-9c73-235b5cc9434a

📥 Commits

Reviewing files that changed from the base of the PR and between 06f73f2 and 11d11b3.

⛔ Files ignored due to path filters (1)
  • Lib/test/test_structseq.py is excluded by !Lib/**
📒 Files selected for processing (1)
  • crates/derive-impl/src/pystructseq.rs

📝 Walkthrough

Walkthrough

This PR refactors the #[pystruct_sequence_data(...)] macro code generation to eliminate conditional branching on empty conditional compilation attributes. Identifier parsing and field indices construction are reformatted to use explicit collection syntax, and token generation for field entries and struct initialization now unconditionally splice cfg_attrs using the repetition form instead of branching.

Changes

PyStructSequence Macro Refactoring

Layer / File(s) Summary
Identifier parsing and field indices refactoring
crates/derive-impl/src/pystructseq.rs
#[pystruct_sequence(...)] identifier parsing and field_indices construction switched to explicit .collect::<Vec<_>>() syntax, preserving filtering and cloning behavior.
Conditional compilation attribute splicing consolidation
crates/derive-impl/src/pystructseq.rs
Token generation for named/skipped field names, tuple conversions, and try_from_elements field initialization refactored to unconditionally splice #(#cfg_attrs)* without empty-check branching; minor whitespace adjustment applied.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • youknowone

Poem

A macro refactors, clean and clear,
No branching bloat to interfere,
With #(#cfg_attrs)* spliced just right,
The code generation shines bright! ✨🐰

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title refers to updating test_structseq.py, but the actual changes are in crates/derive-impl/src/pystructseq.rs—a macro code generation refactor unrelated to the test file. Update the title to reflect the actual changes, such as 'Refactor pystruct_sequence macro code generation to consistently handle cfg attributes' or similar.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 21, 2026

📦 Library Dependencies

The following Lib/ modules were modified. Here are their dependencies:

[x] test: cpython/Lib/test/test_structseq.py (TODO: 7)

dependencies:

dependent tests: (no tests depend on structseq)

Legend:

  • [+] path exists in CPython
  • [x] up-to-date, [ ] outdated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant