René's URL Explorer Experiment


Title: Add `PreCommitConfig.from_system_hook()` to deduplicate backend dispatch in tool specs by Copilot · Pull Request #1606 · usethis-python/usethis-python · GitHub

Open Graph Title: Add `PreCommitConfig.from_system_hook()` to deduplicate backend dispatch in tool specs by Copilot · Pull Request #1606 · usethis-python/usethis-python

X Title: Add `PreCommitConfig.from_system_hook()` to deduplicate backend dispatch in tool specs by Copilot · Pull Request #1606 · usethis-python/usethis-python

Description: Three tool specs (ty, deptry, import_linter) each duplicated ~40 lines of identical backend dispatch logic to construct a local system hook PreCommitConfig. This adds a single classmethod that encapsulates the pattern. New method PreCommitConfig.from_system_hook() handles backend dispatch (prefixing uv run --frozen --offline for uv), system language resolution, and LocalRepo construction internally. It takes only two parameters (hook_id and entry) and hardcodes the common defaults (always_run=True, pass_filenames=False, requires_venv=True, inform_how_to_use_on_migrate=False): # Before: ~40 lines of if/elif/else per tool backend = get_backend() if backend is BackendEnum.uv: return PreCommitConfig.from_single_repo( pre_commit_schema.LocalRepo(repo="local", hooks=[ pre_commit_schema.HookDefinition( id="ty", name="ty", entry="uv run --frozen --offline ty check", language=get_system_language(), ... ) ]), requires_venv=True, inform_how_to_use_on_migrate=False, ) elif backend is BackendEnum.none: # Same thing without the uv prefix... else: assert_never(backend) # After return PreCommitConfig.from_system_hook( hook_id="ty", entry="ty check", ) Changes src/usethis/_tool/pre_commit.py — Added from_system_hook() classmethod with 2 params (hook_id, entry), hardcoding always_run=True, pass_filenames=False src/usethis/_tool/impl/spec/{ty,deptry,import_linter}.py — Replaced backend dispatch blocks with single from_system_hook() calls; removed now-unused imports (get_backend, assert_never, BackendEnum, pre_commit_schema, get_system_language) tests/usethis/_tool/test_pre_commit.py — 10 tests covering both backends, all hook fields, and hardcoded defaults 📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Open Graph Description: Three tool specs (ty, deptry, import_linter) each duplicated ~40 lines of identical backend dispatch logic to construct a local system hook PreCommitConfig. This adds a single classmethod that enca...

X Description: Three tool specs (ty, deptry, import_linter) each duplicated ~40 lines of identical backend dispatch logic to construct a local system hook PreCommitConfig. This adds a single classmethod that enca...

Opengraph URL: https://github.com/usethis-python/usethis-python/pull/1606

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:8c281425-755a-1926-0d8a-f6bc0fffa5f4
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idBF30:179658:FB4553:16F95C8:6A4E35C2
html-safe-noncef0651ef43a67158f7dc3264f58721e206c8159b42a820d1be7670621bec971f8
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRjMwOjE3OTY1ODpGQjQ1NTM6MTZGOTVDODo2QTRFMzVDMiIsInZpc2l0b3JfaWQiOiIyODI1Nzg2NDkwNTE2MDI2ODE4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacf7f2dfdbfec9be9f80d7b912e958f60f5e170903c5c420224a675dc76dcdbc17
hovercard-subject-tagpull_request:3456558804
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/usethis-python/usethis-python/pull/1606/files
twitter:imagehttps://avatars.githubusercontent.com/in/1143301?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/in/1143301?s=400&v=4
og:image:altThree tool specs (ty, deptry, import_linter) each duplicated ~40 lines of identical backend dispatch logic to construct a local system hook PreCommitConfig. This adds a single classmethod that enca...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None030096ee0db095447bfe77409d33bfac127ca7128299c58deef27c52eaa1b1f0
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/usethis-python/usethis-python git https://github.com/usethis-python/usethis-python.git
octolytics-dimension-user_id216362695
octolytics-dimension-user_loginusethis-python
octolytics-dimension-repository_id842189705
octolytics-dimension-repository_nwousethis-python/usethis-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id842189705
octolytics-dimension-repository_network_root_nwousethis-python/usethis-python
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release42a6d378d7587a44c93aca255096cd66b7c8eb2d
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/usethis-python/usethis-python/pull/1606/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fusethis-python%2Fusethis-python%2Fpull%2F1606%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fusethis-python%2Fusethis-python%2Fpull%2F1606%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=usethis-python%2Fusethis-python
Reloadhttps://github.com/usethis-python/usethis-python/pull/1606/files
Reloadhttps://github.com/usethis-python/usethis-python/pull/1606/files
Reloadhttps://github.com/usethis-python/usethis-python/pull/1606/files
Please reload this pagehttps://github.com/usethis-python/usethis-python/pull/1606/files
usethis-python https://github.com/usethis-python
usethis-pythonhttps://github.com/usethis-python/usethis-python
Notifications https://github.com/login?return_to=%2Fusethis-python%2Fusethis-python
Fork 5 https://github.com/login?return_to=%2Fusethis-python%2Fusethis-python
Star 19 https://github.com/login?return_to=%2Fusethis-python%2Fusethis-python
Code https://github.com/usethis-python/usethis-python
Issues 163 https://github.com/usethis-python/usethis-python/issues
Pull requests 4 https://github.com/usethis-python/usethis-python/pulls
Actions https://github.com/usethis-python/usethis-python/actions
Security and quality 0 https://github.com/usethis-python/usethis-python/security
Insights https://github.com/usethis-python/usethis-python/pulse
Code https://github.com/usethis-python/usethis-python
Issues https://github.com/usethis-python/usethis-python/issues
Pull requests https://github.com/usethis-python/usethis-python/pulls
Actions https://github.com/usethis-python/usethis-python/actions
Security and quality https://github.com/usethis-python/usethis-python/security
Insights https://github.com/usethis-python/usethis-python/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fusethis-python%2Fusethis-python%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fusethis-python%2Fusethis-python%2Fissues%2Fnew%2Fchoose
nathanjmcdougallhttps://github.com/nathanjmcdougall
mainhttps://github.com/usethis-python/usethis-python/tree/main
copilot/functionalize-system-hook-config-methodhttps://github.com/usethis-python/usethis-python/tree/copilot/functionalize-system-hook-config-method
Conversation 4 https://github.com/usethis-python/usethis-python/pull/1606
Commits 4 https://github.com/usethis-python/usethis-python/pull/1606/commits
Checks 20 https://github.com/usethis-python/usethis-python/pull/1606/checks
Files changed https://github.com/usethis-python/usethis-python/pull/1606/files
Please reload this pagehttps://github.com/usethis-python/usethis-python/pull/1606/files
Add PreCommitConfig.from_system_hook() to deduplicate backend dispatch in tool specs https://github.com/usethis-python/usethis-python/pull/1606/files#top
Show all changes 4 commits https://github.com/usethis-python/usethis-python/pull/1606/files
6855986 Initial plan Copilot Mar 27, 2026 https://github.com/usethis-python/usethis-python/pull/1606/commits/6855986ecae4b7857e589050c263860a67253286
9dfc7fd Add PreCommitConfig.from_system_hook() and refactor tool specs to use it Copilot Mar 27, 2026 https://github.com/usethis-python/usethis-python/pull/1606/commits/9dfc7fdbdab22b8a72e690d0d88160167d0e426f
ce35a9e Fix PLR0913: reduce from_system_hook arguments to 5 Copilot Mar 27, 2026 https://github.com/usethis-python/usethis-python/pull/1606/commits/ce35a9e2b6d363f4e90e632e96199b78d7ca869c
a48ac59 Hardcode always_run=True, pass_filenames=False; remove require_serial Copilot Mar 27, 2026 https://github.com/usethis-python/usethis-python/pull/1606/commits/a48ac590cb182427a89afc4b66efa84be8179850
Clear filters https://github.com/usethis-python/usethis-python/pull/1606/files
Please reload this pagehttps://github.com/usethis-python/usethis-python/pull/1606/files
Please reload this pagehttps://github.com/usethis-python/usethis-python/pull/1606/files
deptry.py https://github.com/usethis-python/usethis-python/pull/1606/files#diff-a45bc47a5a667207144f963aa8ca348d76e45d2bcb40cf3d6840793e0774e6d0
import_linter.py https://github.com/usethis-python/usethis-python/pull/1606/files#diff-6ae3109858d54e24b0823c4ea22e36b476a7c96fe808145d4b0e0c753c577032
ty.py https://github.com/usethis-python/usethis-python/pull/1606/files#diff-5e660a619687de78df704703a941bede5ffca9a5008bd9a9e5faf363879ec7d8
pre_commit.py https://github.com/usethis-python/usethis-python/pull/1606/files#diff-1a909bc8f54e86f3d1a47a9432e1ebf4a76def0770ac45396d357ef49dba7948
test_pre_commit.py https://github.com/usethis-python/usethis-python/pull/1606/files#diff-0d1e08e23d23ae646d6d169e1bf0c00e656981782fb3f7ca18bd356fd77a59dc
src/usethis/_tool/impl/spec/deptry.pyhttps://github.com/usethis-python/usethis-python/pull/1606/files#diff-a45bc47a5a667207144f963aa8ca348d76e45d2bcb40cf3d6840793e0774e6d0
View file https://github.com/usethis-python/usethis-python/blob/a48ac590cb182427a89afc4b66efa84be8179850/src/usethis/_tool/impl/spec/deptry.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/usethis-python/usethis-python/pull/1606/{{ revealButtonHref }}
https://github.com/usethis-python/usethis-python/pull/1606/files#diff-a45bc47a5a667207144f963aa8ca348d76e45d2bcb40cf3d6840793e0774e6d0
https://github.com/usethis-python/usethis-python/pull/1606/files#diff-a45bc47a5a667207144f963aa8ca348d76e45d2bcb40cf3d6840793e0774e6d0
https://github.com/usethis-python/usethis-python/pull/1606/files#diff-a45bc47a5a667207144f963aa8ca348d76e45d2bcb40cf3d6840793e0774e6d0
https://github.com/usethis-python/usethis-python/pull/1606/files#diff-a45bc47a5a667207144f963aa8ca348d76e45d2bcb40cf3d6840793e0774e6d0
src/usethis/_tool/impl/spec/import_linter.pyhttps://github.com/usethis-python/usethis-python/pull/1606/files#diff-6ae3109858d54e24b0823c4ea22e36b476a7c96fe808145d4b0e0c753c577032
View file https://github.com/usethis-python/usethis-python/blob/a48ac590cb182427a89afc4b66efa84be8179850/src/usethis/_tool/impl/spec/import_linter.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/usethis-python/usethis-python/pull/1606/{{ revealButtonHref }}
https://github.com/usethis-python/usethis-python/pull/1606/files#diff-6ae3109858d54e24b0823c4ea22e36b476a7c96fe808145d4b0e0c753c577032
https://github.com/usethis-python/usethis-python/pull/1606/files#diff-6ae3109858d54e24b0823c4ea22e36b476a7c96fe808145d4b0e0c753c577032
https://github.com/usethis-python/usethis-python/pull/1606/files#diff-6ae3109858d54e24b0823c4ea22e36b476a7c96fe808145d4b0e0c753c577032
https://github.com/usethis-python/usethis-python/pull/1606/files#diff-6ae3109858d54e24b0823c4ea22e36b476a7c96fe808145d4b0e0c753c577032
https://github.com/usethis-python/usethis-python/pull/1606/files#diff-6ae3109858d54e24b0823c4ea22e36b476a7c96fe808145d4b0e0c753c577032
src/usethis/_tool/impl/spec/ty.pyhttps://github.com/usethis-python/usethis-python/pull/1606/files#diff-5e660a619687de78df704703a941bede5ffca9a5008bd9a9e5faf363879ec7d8
View file https://github.com/usethis-python/usethis-python/blob/a48ac590cb182427a89afc4b66efa84be8179850/src/usethis/_tool/impl/spec/ty.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/usethis-python/usethis-python/pull/1606/{{ revealButtonHref }}
https://github.com/usethis-python/usethis-python/pull/1606/files#diff-5e660a619687de78df704703a941bede5ffca9a5008bd9a9e5faf363879ec7d8
https://github.com/usethis-python/usethis-python/pull/1606/files#diff-5e660a619687de78df704703a941bede5ffca9a5008bd9a9e5faf363879ec7d8
https://github.com/usethis-python/usethis-python/pull/1606/files#diff-5e660a619687de78df704703a941bede5ffca9a5008bd9a9e5faf363879ec7d8
https://github.com/usethis-python/usethis-python/pull/1606/files#diff-5e660a619687de78df704703a941bede5ffca9a5008bd9a9e5faf363879ec7d8
src/usethis/_tool/pre_commit.pyhttps://github.com/usethis-python/usethis-python/pull/1606/files#diff-1a909bc8f54e86f3d1a47a9432e1ebf4a76def0770ac45396d357ef49dba7948
View file https://github.com/usethis-python/usethis-python/blob/a48ac590cb182427a89afc4b66efa84be8179850/src/usethis/_tool/pre_commit.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/usethis-python/usethis-python/pull/1606/{{ revealButtonHref }}
https://github.com/usethis-python/usethis-python/pull/1606/files#diff-1a909bc8f54e86f3d1a47a9432e1ebf4a76def0770ac45396d357ef49dba7948
https://github.com/usethis-python/usethis-python/pull/1606/files#diff-1a909bc8f54e86f3d1a47a9432e1ebf4a76def0770ac45396d357ef49dba7948
https://github.com/usethis-python/usethis-python/pull/1606/files#diff-1a909bc8f54e86f3d1a47a9432e1ebf4a76def0770ac45396d357ef49dba7948
Please reload this pagehttps://github.com/usethis-python/usethis-python/pull/1606/files
Please reload this pagehttps://github.com/usethis-python/usethis-python/pull/1606/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.