René's URL Explorer Experiment


Title: Forbid `functools.singledispatch` / `singledispatchmethod` via Ruff banned-api by Copilot · Pull Request #1361 · usethis-python/usethis-python · GitHub

Open Graph Title: Forbid `functools.singledispatch` / `singledispatchmethod` via Ruff banned-api by Copilot · Pull Request #1361 · usethis-python/usethis-python

X Title: Forbid `functools.singledispatch` / `singledispatchmethod` via Ruff banned-api by Copilot · Pull Request #1361 · usethis-python/usethis-python

Description: functools.singledispatch has poor static analysis semantics. This PR bans it via Ruff's flake8-tidy-imports.banned-api and replaces all existing usages with explicit isinstance-based if-branch dispatch. Config Added to pyproject.toml: lint.flake8-tidy-imports.banned-api."functools.singledispatch".msg = "Use if-branch isinstance logic instead of singledispatch." lint.flake8-tidy-imports.banned-api."functools.singledispatchmethod".msg = "Use if-branch isinstance logic instead of singledispatchmethod." Refactoring pattern All @singledispatch / @singledispatchmethod usages replaced: # Before @singledispatch def _as_dict(value: INIDocument | Section) -> ...: raise NotImplementedError @_as_dict.register(INIDocument) def _(value: INIDocument) -> ...: return {k: _as_dict(v) for k, v in value.items()} @_as_dict.register(Section) def _(value: Section) -> ...: return {option.key: option.value for option in value.iter_options()} # After def _as_dict(value: INIDocument | Section) -> ...: if isinstance(value, INIDocument): return {k: _as_dict(v) for k, v in value.items()} elif isinstance(value, Section): return {option.key: option.value for option in value.iter_options()} else: assert_never(value) Files changed _file/ini/io_.py — _as_dict _pipeweld/func.py — Adder.partition_component (method) and _get_instructions_for_insertion; complex branches extracted into _partition_series_component, _partition_parallel_component, _partition_depgroup_component _integrations/ci/bitbucket/pipeweld.py — get_pipeweld_object, _extract_step_from_item, _insert_parallel_step, _is_insertion_necessary; extracted _extract_step_from_parallel_item _integrations/ci/bitbucket/steps.py — _censor_step, get_steps_in_pipeline_item; extracted _censor_parallel_item_step, _censor_stage_item_step _integrations/pydantic/dump.py — fancy_model_dump; extracted _fancy_model_dump_list, _fancy_model_dump_dict, _fancy_model_dump_base_model Where functions were large, helpers were extracted to stay within Ruff's branch/return-count limits (PLR0912, PLR0911). All dispatch exhaustiveness is enforced via assert_never. Original prompt This section details on the original issue you should resolve Forbid usage of functools.singledispatch Toward #1340. singledispatch has semantics which don't play nicely with static analysis. Arguably, they're needlessly verbose. I would prefer to refactor just use if-branch logic. We should set up a Ruff rule for this, e.g. using example config from docs: banned-api Specific modules or module members that may not be imported or accessed. Note that this rule is only meant to flag accidental uses, and can be circumvented via eval or importlib. Default value: {} Type: dict[str, { "msg": str }] Example usage: pyproject.toml ruff.toml [lint.flake8-tidy-imports.banned-api] "cgi".msg = "The cgi module is deprecated, see https://peps.python.org/pep-0594/#cgi." "typing.TypedDict".msg = "Use typing_extensions.TypedDict instead." Comments on the Issue (you are @copilot in this section) Fixes #1360 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Open Graph Description: functools.singledispatch has poor static analysis semantics. This PR bans it via Ruff's flake8-tidy-imports.banned-api and replaces all existing usages with explicit isinstance-based if-branch ...

X Description: functools.singledispatch has poor static analysis semantics. This PR bans it via Ruff's flake8-tidy-imports.banned-api and replaces all existing usages with explicit isinstance-based if-bra...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:1733505d-e6d8-555e-8928-96e301b174a4
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idB970:326119:51025:6D905:6A4D7902
html-safe-nonce5f0a51df4b485797371b804f05fb704261ffab28f30b6e892b68a8698cfda5bb
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOTcwOjMyNjExOTo1MTAyNTo2RDkwNTo2QTRENzkwMiIsInZpc2l0b3JfaWQiOiIxMzY1NDA2NDc5MjU5ODkxOTcwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac7b2374aa62cd54ee12d48a1ea5e0e161e1364e536e97ee6b04384f2e72e18150
hovercard-subject-tagpull_request:3381478063
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/1361/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:altfunctools.singledispatch has poor static analysis semantics. This PR bans it via Ruff's flake8-tidy-imports.banned-api and replaces all existing usages with explicit isinstance-based if-branch ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None7f8e15305e2ab58890ca84b830615e375f5df303cf471cafcba0c08272981be3
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
release8608b0750fc35e283e5ec5b094bff942d7a0e197
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/usethis-python/usethis-python/pull/1361/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%2F1361%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%2F1361%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/1361/files
Reloadhttps://github.com/usethis-python/usethis-python/pull/1361/files
Reloadhttps://github.com/usethis-python/usethis-python/pull/1361/files
Please reload this pagehttps://github.com/usethis-python/usethis-python/pull/1361/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/forbid-usage-of-functools-singledispatchhttps://github.com/usethis-python/usethis-python/tree/copilot/forbid-usage-of-functools-singledispatch
Conversation 2 https://github.com/usethis-python/usethis-python/pull/1361
Commits 3 https://github.com/usethis-python/usethis-python/pull/1361/commits
Checks 20 https://github.com/usethis-python/usethis-python/pull/1361/checks
Files changed https://github.com/usethis-python/usethis-python/pull/1361/files
Please reload this pagehttps://github.com/usethis-python/usethis-python/pull/1361/files
Forbid functools.singledispatch / singledispatchmethod via Ruff banned-api https://github.com/usethis-python/usethis-python/pull/1361/files#top
Show all changes 3 commits https://github.com/usethis-python/usethis-python/pull/1361/files
70ddc76 Initial plan Copilot Mar 11, 2026 https://github.com/usethis-python/usethis-python/pull/1361/commits/70ddc76d521f7dcf7cc2faa4fbaf438ab2345081
6c32fe2 refactor: replace singledispatch with isinstance if-branch logic and … Copilot Mar 11, 2026 https://github.com/usethis-python/usethis-python/pull/1361/commits/6c32fe221d32365fc9314c78fccd153fd8275149
47127e7 style: apply ruff format to refactored files Copilot Mar 11, 2026 https://github.com/usethis-python/usethis-python/pull/1361/commits/47127e7fe64f738e0ce4cf3e3aef2e7f580e776d
Clear filters https://github.com/usethis-python/usethis-python/pull/1361/files
Please reload this pagehttps://github.com/usethis-python/usethis-python/pull/1361/files
Please reload this pagehttps://github.com/usethis-python/usethis-python/pull/1361/files
pyproject.toml https://github.com/usethis-python/usethis-python/pull/1361/files#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711
io_.py https://github.com/usethis-python/usethis-python/pull/1361/files#diff-680425dcb2a48b3e343c57178815867194841e035f7fad833eb702438b48ca0f
pipeweld.py https://github.com/usethis-python/usethis-python/pull/1361/files#diff-31e84deca1e3a0c223667c1d677f7aa2257a9813d0da79f899330c90063e901a
steps.py https://github.com/usethis-python/usethis-python/pull/1361/files#diff-157eb8acd88d2ce77bab7ff7e2d87706c6763e74a9305e658f2fa82f156ef43c
dump.py https://github.com/usethis-python/usethis-python/pull/1361/files#diff-277ada7ad72ab4ac5f17bbe334a336d69ed23859db01fa47e74a7480949f310a
func.py https://github.com/usethis-python/usethis-python/pull/1361/files#diff-a9fec0a37f88a7dce6d62998d4adfa8161560ae5c83f8e95c15e15c4b3b5c2a3
pyproject.tomlhttps://github.com/usethis-python/usethis-python/pull/1361/files#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711
View file https://github.com/usethis-python/usethis-python/blob/47127e7fe64f738e0ce4cf3e3aef2e7f580e776d/pyproject.toml
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/usethis-python/usethis-python/pull/1361/{{ revealButtonHref }}
https://github.com/usethis-python/usethis-python/pull/1361/files#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711
https://github.com/usethis-python/usethis-python/pull/1361/files#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711
src/usethis/_file/ini/io_.pyhttps://github.com/usethis-python/usethis-python/pull/1361/files#diff-680425dcb2a48b3e343c57178815867194841e035f7fad833eb702438b48ca0f
View file https://github.com/usethis-python/usethis-python/blob/47127e7fe64f738e0ce4cf3e3aef2e7f580e776d/src/usethis/_file/ini/io_.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/usethis-python/usethis-python/pull/1361/{{ revealButtonHref }}
https://github.com/usethis-python/usethis-python/pull/1361/files#diff-680425dcb2a48b3e343c57178815867194841e035f7fad833eb702438b48ca0f
https://github.com/usethis-python/usethis-python/pull/1361/files#diff-680425dcb2a48b3e343c57178815867194841e035f7fad833eb702438b48ca0f
https://github.com/usethis-python/usethis-python/pull/1361/files#diff-680425dcb2a48b3e343c57178815867194841e035f7fad833eb702438b48ca0f
https://github.com/usethis-python/usethis-python/pull/1361/files#diff-680425dcb2a48b3e343c57178815867194841e035f7fad833eb702438b48ca0f
src/usethis/_integrations/ci/bitbucket/pipeweld.pyhttps://github.com/usethis-python/usethis-python/pull/1361/files#diff-31e84deca1e3a0c223667c1d677f7aa2257a9813d0da79f899330c90063e901a
View file https://github.com/usethis-python/usethis-python/blob/47127e7fe64f738e0ce4cf3e3aef2e7f580e776d/src/usethis/_integrations/ci/bitbucket/pipeweld.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/usethis-python/usethis-python/pull/1361/{{ revealButtonHref }}
https://github.com/usethis-python/usethis-python/pull/1361/files#diff-31e84deca1e3a0c223667c1d677f7aa2257a9813d0da79f899330c90063e901a
https://github.com/usethis-python/usethis-python/pull/1361/files#diff-31e84deca1e3a0c223667c1d677f7aa2257a9813d0da79f899330c90063e901a
https://github.com/usethis-python/usethis-python/pull/1361/files#diff-31e84deca1e3a0c223667c1d677f7aa2257a9813d0da79f899330c90063e901a
https://github.com/usethis-python/usethis-python/pull/1361/files#diff-31e84deca1e3a0c223667c1d677f7aa2257a9813d0da79f899330c90063e901a
https://github.com/usethis-python/usethis-python/pull/1361/files#diff-31e84deca1e3a0c223667c1d677f7aa2257a9813d0da79f899330c90063e901a
https://github.com/usethis-python/usethis-python/pull/1361/files#diff-31e84deca1e3a0c223667c1d677f7aa2257a9813d0da79f899330c90063e901a
https://github.com/usethis-python/usethis-python/pull/1361/files#diff-31e84deca1e3a0c223667c1d677f7aa2257a9813d0da79f899330c90063e901a
https://github.com/usethis-python/usethis-python/pull/1361/files#diff-31e84deca1e3a0c223667c1d677f7aa2257a9813d0da79f899330c90063e901a
https://github.com/usethis-python/usethis-python/pull/1361/files#diff-31e84deca1e3a0c223667c1d677f7aa2257a9813d0da79f899330c90063e901a
Please reload this pagehttps://github.com/usethis-python/usethis-python/pull/1361/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.