refactor: hoist shared if-else logic; document principle in skill#1890
Merged
nathanjmcdougall merged 4 commits intoApr 8, 2026
Merged
Conversation
…lse nesting skill guidance Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/666ce694-85bc-4b4e-9d64-4dd29447b897 Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor uninstall_pre_commit_hooks to eliminate duplicated string literals
refactor: hoist shared if-else logic; document principle in skill
Apr 8, 2026
nathanjmcdougall
approved these changes
Apr 8, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Also fix priority config issues in prek
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.
When an if-elif chain branches on a backend enum, identical statements appearing in multiple sibling branches signal a structural problem — the shared logic should be hoisted to an outer combined membership check.
Code fix (
src/usethis/_deps.py)remove_deps_from_group()had the sametick_printcall duplicated verbatim in both theuvandpoetrybranches:Skill update (
.agents/skills/usethis-python-code/SKILL.md, v1.9 → v1.10)Added section "Structuring if-else to avoid duplicated logic" — the generalised principle, a procedure, a before/after example, and common mistakes (including the nested-guard variant where the same guard condition is independently checked inside each backend branch).