René's URL Explorer Experiment


Title: Add cross-language method suggestions for builtin AttributeError · Issue #146406 · python/cpython · GitHub

Open Graph Title: Add cross-language method suggestions for builtin AttributeError · Issue #146406 · python/cpython

X Title: Add cross-language method suggestions for builtin AttributeError · Issue #146406 · python/cpython

Description: Proposal When an AttributeError occurs on a builtin type (list, str, dict) and the existing Levenshtein-based suggestion system finds no match, check a static table of common method names from other programming languages. Before: >>> [1,...

Open Graph Description: Proposal When an AttributeError occurs on a builtin type (list, str, dict) and the existing Levenshtein-based suggestion system finds no match, check a static table of common method names from othe...

X Description: Proposal When an AttributeError occurs on a builtin type (list, str, dict) and the existing Levenshtein-based suggestion system finds no match, check a static table of common method names from othe...

Opengraph URL: https://github.com/python/cpython/issues/146406

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add cross-language method suggestions for builtin AttributeError","articleBody":"## Proposal\n\nWhen an `AttributeError` occurs on a builtin type (`list`, `str`, `dict`) and the existing Levenshtein-based suggestion system finds no match, check a static table of common method names from other programming languages.\n\n**Before:**\n```python\n>>> [1, 2, 3].push(4)\nAttributeError: 'list' object has no attribute 'push'\n```\n\n**After:**\n```python\n>>> [1, 2, 3].push(4)\nAttributeError: 'list' object has no attribute 'push'. Did you mean '.append' instead of '.push'?\n```\n\n## Discourse discussion\n\nThis was discussed at https://discuss.python.org/t/cross-language-method-suggestions-for-attributeerror/106632 (420 views, 25 likes, 3 core devs participated).\n\nDesign decisions from the discussion:\n\n- **Flat table approach** per @pf_moore ([post 14](https://discuss.python.org/t/106632/14), 4 likes): each (type, attr) entry carries the exact suggestion text. No runtime introspection of related types needed.\n\n- **list.add() suggests using a set** per @storchaka ([post 8](https://discuss.python.org/t/106632/8)) and @tjreedy ([post 12](https://discuss.python.org/t/106632/12)): \"It can also mean that you passed a list instead of set.\" The table maps this to a wrong-type hint rather than suggesting append.\n\n- **Option 1: static table for builtins only** - community consensus. 11 entries covering JS/Java/C#/Ruby. Inclusion criteria: evidence of real confusion, not catchable by Levenshtein, from a top-4 language.\n\n- **Scope guardrails** per @dr_carlos ([post 3](https://discuss.python.org/t/106632/3)): \"only add entries with clear evidence of real confusion, not just because two methods do similar things.\"\n\n## Examples\n\n| What user writes | Before | After |\n|---|---|---|\n| `[].push(4)` | no suggestion | Did you mean '.append'? |\n| `\"\".toUpperCase()` | no suggestion | Did you mean '.upper'? |\n| `{}.keySet()` | no suggestion | Did you mean '.keys'? |\n| `[].add(1)` | no suggestion | Did you mean to use a set? |\n| `\"\".trimStart()` | no suggestion | Did you mean '.lstrip'? |\n\nEntries where Levenshtein already provides a match (indexOf->index, trim->strip) are intentionally excluded from the table since they already work.\n\n## Implementation\n\n~60 lines in `Lib/traceback.py`: a dict mapping (builtin_type, wrong_name) to suggestion text, a small lookup function, and a 4-line hook in `TracebackException.__init__` that runs only when Levenshtein found nothing. Tests cover all entries plus priority ordering and subclass exclusion.\n\n## Has this already been discussed elsewhere?\n\nYes, on Discourse: https://discuss.python.org/t/106632\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-146407\n* gh-149927\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/mvanhorn","@type":"Person","name":"mvanhorn"},"datePublished":"2026-03-25T07:13:57Z","url":"https://github.com/python/cpython/issues/146406"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:af204ff5-4699-3d81-9b7b-9d06e3e415ed
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBCDC:148EE1:AFB9F8:DD52E5:6B0222E3
html-safe-nonce69ed99db2711f604d85802480fb3460c40b04a769d56bc04f422d2ca3492961a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQ0RDOjE0OEVFMTpBRkI5Rjg6REQ1MkU1OjZCMDIyMkUzIiwidmlzaXRvcl9pZCI6IjYzMjYxMTYzOTY0NjM5NTY3MDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac374a5a2e001764b69be2675294ccd7e921184c9eeed1fc8f091a74f66bcd078a
hovercard-subject-tagissue:4133181967
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/146406/issue_layout
twitter:imagehttps://opengraph.githubassets.com/503a5edacda7c03c8eb06d632952d0eb06d0626ba500584d5649b45bb1d0e04f/python/cpython/issues/146406
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/503a5edacda7c03c8eb06d632952d0eb06d0626ba500584d5649b45bb1d0e04f/python/cpython/issues/146406
og:image:altProposal When an AttributeError occurs on a builtin type (list, str, dict) and the existing Levenshtein-based suggestion system finds no match, check a static table of common method names from othe...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemvanhorn
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/146406#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F146406
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
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
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://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/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F146406
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/146406
Reloadhttps://github.com/python/cpython/issues/146406
Reloadhttps://github.com/python/cpython/issues/146406
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/146406
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/146406
#146407https://github.com/python/cpython/pull/146407
Add cross-language method suggestions for builtin AttributeErrorhttps://github.com/python/cpython/issues/146406#top
#146407https://github.com/python/cpython/pull/146407
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
topic-replRelated to the interactive shellhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-repl%22
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
https://github.com/mvanhorn
mvanhornhttps://github.com/mvanhorn
on Mar 25, 2026https://github.com/python/cpython/issues/146406#issue-4133181967
https://discuss.python.org/t/cross-language-method-suggestions-for-attributeerror/106632https://discuss.python.org/t/cross-language-method-suggestions-for-attributeerror/106632
post 14https://discuss.python.org/t/106632/14
@Storchakahttps://github.com/Storchaka
post 8https://discuss.python.org/t/106632/8
@tjreedyhttps://github.com/tjreedy
post 12https://discuss.python.org/t/106632/12
post 3https://discuss.python.org/t/106632/3
https://discuss.python.org/t/106632https://discuss.python.org/t/106632
gh-146406: Add cross-language method suggestions for builtin AttributeError #146407https://github.com/python/cpython/pull/146407
gh-146406: add clear() cross-language hint for immutable types #149927https://github.com/python/cpython/pull/149927
https://github.com/picnixz
picnixzhttps://github.com/picnixz
on Mar 25, 2026https://github.com/python/cpython/issues/146406#issuecomment-4124491262
picnixzhttps://github.com/picnixz
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
topic-replRelated to the interactive shellhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-repl%22
on Mar 25, 2026https://github.com/python/cpython/issues/146406#event-23880503768
https://github.com/serhiy-storchaka
serhiy-storchakahttps://github.com/serhiy-storchaka
on Mar 26, 2026https://github.com/python/cpython/issues/146406#issuecomment-4133090854
https://github.com/picnixz
picnixzhttps://github.com/picnixz
on Mar 26, 2026https://github.com/python/cpython/issues/146406#issuecomment-4133205753
https://github.com/serhiy-storchaka
serhiy-storchakahttps://github.com/serhiy-storchaka
on Mar 26, 2026https://github.com/python/cpython/issues/146406#issuecomment-4133307177
https://github.com/picnixz
picnixzhttps://github.com/picnixz
on Mar 26, 2026https://github.com/python/cpython/issues/146406#issuecomment-4133342552
vstinnerhttps://github.com/vstinner
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#146407https://github.com/python/cpython/pull/146407
on May 4, 2026https://github.com/python/cpython/issues/146406#event-25151785568
vstinnerhttps://github.com/vstinner
on May 4, 2026https://github.com/python/cpython/issues/146406#event-25151785643
gh-146406: Add cross-language method suggestions for builtin Attribut…https://github.com/python/cpython/commit/7acee984e8e2a88bcfb7a83e9c472902e340e5be
gh-146406https://github.com/python/cpython/issues/146406
7acee98https://github.com/python/cpython/commit/7acee984e8e2a88bcfb7a83e9c472902e340e5be
ZeroIntensityhttps://github.com/ZeroIntensity
on May 20, 2026https://github.com/python/cpython/issues/146406#event-25736896023
gh-146406: add clear() cross-language hint for immutable types (GH-14…https://github.com/python/cpython/commit/d948eaa366029bc358dbe9cf32d545c3ad30c502
gh-146406https://github.com/python/cpython/issues/146406
GH-14…https://github.com/python/cpython/pull/149927
d948eaahttps://github.com/python/cpython/commit/d948eaa366029bc358dbe9cf32d545c3ad30c502
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/146406
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/146406
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
topic-replRelated to the interactive shellhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-repl%22
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
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.