-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
gh-130425: Add "Did you mean [...]" suggestions for del obj.attr
#136588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
del obj.attr
Misc/NEWS.d/next/Core_and_Builtins/2025-02-22-01-23-23.gh-issue-130425.x5SNQ8.rst
Show resolved
Hide resolved
Doc/whatsnew/3.15.rst
Outdated
@@ -175,6 +175,20 @@ Other language changes | |||
* Several error messages incorrectly using the term "argument" have been corrected. | |||
(Contributed by Stan Ulbrych in :gh:`133382`.) | |||
|
|||
* The interpreter now provides helpful suggestions when :func:`delattr` fails due to a missing attribute. When an attribute name that closely resembles an existing attribute is used, the interpreter will suggest the correct attribute name in the error message. For example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you wrap the text under 80 characters per line?
Doc/whatsnew/3.15.rst
Outdated
... pass | ||
>>> a = A() | ||
>>> a.abcde = 1 | ||
>>> del a.abcdf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need # doctest: +ELLIPSIS
Doc/whatsnew/3.15.rst
Outdated
... | ||
AttributeError: 'A' object has no attribute 'abcdf'. Did you mean: 'abcde'? | ||
|
||
(Contributed by [sobolevn] and Pranjal Prajapati in :gh:`136588`.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
soblevn is Nikita Sobolev
This pull request replaces the earlier PR #130799 (now closed) and carries over that set of commits, preserving original authorship and history. An extra commit has been included to address a linting issue that was present in the previous version.
Issue: #130425