8000 chore: pattern matching by henryiii · Pull Request #2434 · pypa/cibuildwheel · GitHub
[go: up one dir, main page]

Skip to content

chore: pattern matching #2434

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

Merged
merged 4 commits into from
Jul 8, 2025
Merged

chore: pattern matching #2434

merged 4 commits into from
Jul 8, 2025

Conversation

henryiii
Copy link
Contributor

Adding some pattern matching where I think it makes sense to do so.

henryiii added 2 commits May 29, 2025 13:25
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
@henryiii henryiii requested a review from Copilot May 29, 2025 22:05
Copilot

This comment was marked as outdated.

@joerick
Copy link
Contributor
joerick commented May 29, 2025

Do you mind if we punt this to after v3.0? Big diffs like this seem like unecessary risk when tapering to a release.

@henryiii henryiii added the Hold for future release This PR might be complete, but is scheduled to be merged in a future release. Don't merge yet. label May 29, 2025
@henryiii
Copy link
Contributor Author

Sure, I even almost added the tag when I opened it.

@joerick joerick removed the Hold for future release This PR might be complete, but is scheduled to be merged in a future release. Don't merge yet. label Jun 11, 2025
@henryiii henryiii requested a review from Copilot June 19, 2025 16:22
Copy link
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR converts several conditional chains to Python's pattern matching syntax to streamline the code.

  • Refactored AST checking in projectfiles.py
  • Replaced if/elif chains with match-case in platforms modules (windows, macos, linux, ios) and oci_container.py
  • Applied pattern matching for merging rules and settings conversion in options.py

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
cibuildwheel/projectfiles.py Converted AST conditionals to a match-case construct for evaluating if a node is the main check.
cibuildwheel/platforms/windows.py Replaced string comparisons with match-case on build frontend values.
cibuildwheel/platforms/macos.py Updated build and setup routines to use pattern matching consistently.
cibuildwheel/platforms/linux.py Simplified build_in_container logic with match-case on build frontend names.
cibuildwheel/platforms/ios.py Enhanced build and setup logic by using pattern matching for cleaner control flow.
cibuildwheel/options.py Switched to match-case for merging options and stringifying settings, although a potential issue exists.
cibuildwheel/oci_container.py Replaced if-elif comparisons with a match-case structure for engine version validation.

Copy link
Member
@mayeut mayeut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AST one is really nice !
I don't see a reason to hold-off merging that one but since it's already approved by @joerick and not merged yet so I won't merge.

@joerick
Copy link
Contributor
joerick commented Jul 8, 2025

yeah, let's get this in now. I'll let you hit the button henryiii, just in case there's something else you wanted to address here.

@henryiii henryiii merged commit 834ea40 into pypa:main Jul 8, 2025
28 checks passed
@henryiii henryiii deleted the henryiii/chore/match branch July 8, 2025 12:59
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.

3 participants
0