FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-146406: add clear() cross-language hint for immutable types by mvanhorn · Pull Request #149927 · python/cpython · GitHub

Repository navigation

gh-146406: add clear() cross-language hint for immutable types - #149927

Merged
ZeroIntensity merged 1 commit into
python:mainfrom
mvanhorn:osc/clear-cross-language-hints
May 20, 2026
Merged

ZeroIntensity merged 1 commit into
python:mainfrom
mvanhorn:osc/clear-cross-language-hints

Conversation

mvanhorn commented May 16, 2026 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

Follow-up to #146407. Calling .clear() on a tuple, frozenset, or frozendict now suggests the mutable counterpart, mirroring the existing append/extend/insert/remove/discard/update entries for the same immutable types.

Requested by @vstinner after @henryiii flagged that .clear() was the first method they tried on these types in the new hint table from #146407 and got no useful suggestion.

>>> (1, 2, 3).clear()
AttributeError: 'tuple' object has no attribute 'clear'. Did you mean to use a 'list' object?
>>> frozenset({1, 2, 3}).clear()
AttributeError: 'frozenset' object has no attribute 'clear'. Did you mean to use a 'set' object?

Verified locally: ./python.exe -m test test_traceback 434/434 passing.

Follow-up to PR python#146407. Calling .clear() on a tuple, frozenset, or
frozendict now suggests the mutable counterpart (list / set / dict),
mirroring the existing append/extend/insert/remove/discard/update
entries for the same immutable types.

Triggered by @henryiii noticing that .clear() was the first method
they tried on these types and got no useful suggestion, and
@vstinner agreeing it was worth adding.

Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>

vstinner left a comment •
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM.

@ZeroIntensity @picnixz: Do you want to double check the change?

picnixz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM

ZeroIntensity merged commit d948eaa into python:main May 20, 2026
58 checks passed
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL