refactor: cleanup anti-patterns#3075
Merged
Merged
Conversation
Extract the closure-immediately-invoked-for-error-context pattern
in add_data() into a proper named function add_data_subdir(). This
replaces the '(|| { ... })().with_context(...)' idiom with a clean
function call that is easier to read and debug.
- main.rs: Extract ensure_release_profile() to deduplicate PEP 517 profile defaulting in WriteDistInfo and BuildWheel handlers - auditwheel/musllinux.rs: Fall back to /usr/bin/ls when /bin/ls doesn't exist, fixing compatibility with distros that don't symlink /bin -> /usr/bin
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors and cleans up a few small anti-patterns by extracting helper logic, deduplicating profile defaults for PEP 517 builds, and improving musl libc detection robustness.
Changes:
- Extracted data-subdirectory walking logic into a helper function in
module_writer. - Centralized “default to release profile” behavior for PEP 517 builds via a local helper.
- Made musl libc detection more robust by falling back from
/bin/lsto/usr/bin/ls.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/module_writer/mod.rs | Extracts per-subdir walk/add logic into add_data_subdir for cleaner control flow. |
| src/main.rs | Adds BuildContext import and factors out release-profile defaulting for PEP 517 builds. |
| src/auditwheel/musllinux.rs | Improves libc interpreter detection by trying an alternate ls path. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
No description provided.