Title: refactor: hoist shared if-else logic; document principle in skill by Copilot · Pull Request #1890 · usethis-python/usethis-python · GitHub
Open Graph Title: refactor: hoist shared if-else logic; document principle in skill by Copilot · Pull Request #1890 · usethis-python/usethis-python
X Title: refactor: hoist shared if-else logic; document principle in skill by Copilot · Pull Request #1890 · usethis-python/usethis-python
Description: 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 same tick_print call duplicated verbatim in both the uv and poetry branches: # Before: identical tick_print in two sibling branches if backend is BackendEnum.uv: tick_print(f"Removing dependenc{ies} {deps_str} from the '{group}' group in 'pyproject.toml'.") for dep in _deps: remove_dep_from_group_via_uv(dep, group) elif backend is BackendEnum.poetry: tick_print(f"Removing dependenc{ies} {deps_str} from the '{group}' group in 'pyproject.toml'.") for dep in _deps: remove_dep_from_group_via_poetry(dep, group) # After: shared message hoisted; distinguishing logic nested inside if backend in (BackendEnum.uv, BackendEnum.poetry): tick_print(f"Removing dependenc{ies} {deps_str} from the '{group}' group in 'pyproject.toml'.") if backend is BackendEnum.uv: for dep in _deps: remove_dep_from_group_via_uv(dep, group) elif backend is BackendEnum.poetry: for dep in _deps: remove_dep_from_group_via_poetry(dep, group) else: assert_never(backend) 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).
Open Graph Description: 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 m...
X Description: 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 m...
Opengraph URL: https://github.com/usethis-python/usethis-python/pull/1890
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:09ce09ff-75ad-116a-2414-6ce61f9998dd |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | BC6C:B97C3:27C7E76:36976AE:6A4EF376 |
| html-safe-nonce | 64a3e53ab351848fc4cf4c7fd8ad98c6a3d2d890d5935adaa21a9322b6e0f8ec |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQzZDOkI5N0MzOjI3QzdFNzY6MzY5NzZBRTo2QTRFRjM3NiIsInZpc2l0b3JfaWQiOiIyMjYyODU4MDA3NjM2Mjc2MDg2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 14ee4f97a3755a2ffcaf9753fdf455d9b0db60cf1d9d16749ef15ecccefd611a |
| hovercard-subject-tag | pull_request:3500683177 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/usethis-python/usethis-python/pull/1890/files |
| twitter:image | https://avatars.githubusercontent.com/in/1143301?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/in/1143301?s=400&v=4 |
| og:image:alt | 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 m... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b92d11c0aa4a77d54ef4af1078b6a15fb5a70a215b30c4ecf28889d5a8e656d9 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/usethis-python/usethis-python git https://github.com/usethis-python/usethis-python.git |
| octolytics-dimension-user_id | 216362695 |
| octolytics-dimension-user_login | usethis-python |
| octolytics-dimension-repository_id | 842189705 |
| octolytics-dimension-repository_nwo | usethis-python/usethis-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 842189705 |
| octolytics-dimension-repository_network_root_nwo | usethis-python/usethis-python |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2b8f23afb982271f1b22258a94aede67a6b77760 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width