Skip to content

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

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

Pranjal095
Copy link

@Pranjal095 Pranjal095 commented Jul 12, 2025

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

@picnixz picnixz changed the title gh-130425: Add "Did you mean [...]" suggestions for del obj.attr gh-130425: Add "Did you mean [...]" suggestions for del obj.attr Jul 12, 2025
@picnixz picnixz requested a review from sobolevn July 12, 2025 15:57
@Pranjal095 Pranjal095 requested a review from picnixz July 12, 2025 18:02
@Pranjal095 Pranjal095 requested a review from picnixz July 12, 2025 18:35
@@ -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:
Copy link
Member

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?

... pass
>>> a = A()
>>> a.abcde = 1
>>> del a.abcdf
Copy link
Member

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

...
AttributeError: 'A' object has no attribute 'abcdf'. Did you mean: 'abcde'?

(Contributed by [sobolevn] and Pranjal Prajapati in :gh:`136588`.)
Copy link
Member

Choose a reason for hiding this comment

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

soblevn is Nikita Sobolev

@Pranjal095 Pranjal095 requested a review from picnixz July 12, 2025 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy