Mailing List Archive

[issue38530] Offer suggestions on AttributeError and NameError
Change by Pablo Galindo Salgado <pablogsal@gmail.com>:


----------
title: Offer suggestions on AttributeError -> Offer suggestions on AttributeError and NameError

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue38530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue38530] Offer suggestions on AttributeError and NameError [ In reply to ]
Change by Pablo Galindo Salgado <pablogsal@gmail.com>:


----------
pull_requests: +24129
pull_request: https://github.com/python/cpython/pull/25397

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue38530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue38530] Offer suggestions on AttributeError and NameError [ In reply to ]
Change by Andre Roberge <andre.roberge@gmail.com>:


----------
nosy: +aroberge

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue38530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue38530] Offer suggestions on AttributeError and NameError [ In reply to ]
Pablo Galindo Salgado <pablogsal@gmail.com> added the comment:


New changeset 5bf8bf2267cd109970b2d946d43b2e9f71379ba2 by Pablo Galindo in branch 'master':
bpo-38530: Offer suggestions on NameError (GH-25397)
https://github.com/python/cpython/commit/5bf8bf2267cd109970b2d946d43b2e9f71379ba2


----------

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue38530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue38530] Offer suggestions on AttributeError and NameError [ In reply to ]
Change by Pablo Galindo Salgado <pablogsal@gmail.com>:


----------
pull_requests: +24141
pull_request: https://github.com/python/cpython/pull/25408

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue38530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue38530] Offer suggestions on AttributeError and NameError [ In reply to ]
Pablo Galindo Salgado <pablogsal@gmail.com> added the comment:


New changeset e07f4ab26aaf08f90ebd9e6004af14fd6ef39351 by Pablo Galindo in branch 'master':
bpo-38530: Make sure that failing to generate suggestions on failure will not propagate exceptions (GH-25408)
https://github.com/python/cpython/commit/e07f4ab26aaf08f90ebd9e6004af14fd6ef39351


----------

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue38530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue38530] Offer suggestions on AttributeError and NameError [ In reply to ]
Change by Pablo Galindo Salgado <pablogsal@gmail.com>:


----------
pull_requests: +24144
pull_request: https://github.com/python/cpython/pull/25412

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue38530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue38530] Offer suggestions on AttributeError and NameError [ In reply to ]
Pablo Galindo Salgado <pablogsal@gmail.com> added the comment:


New changeset 3fc65b97d09fd29272fdf60d2e567bfb070da824 by Pablo Galindo in branch 'master':
bpo-38530: Optimize the calculation of string sizes when offering suggestions (GH-25412)
https://github.com/python/cpython/commit/3fc65b97d09fd29272fdf60d2e567bfb070da824


----------

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue38530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue38530] Offer suggestions on AttributeError and NameError [ In reply to ]
Change by Pablo Galindo Salgado <pablogsal@gmail.com>:


----------
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue38530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue38530] Offer suggestions on AttributeError and NameError [ In reply to ]
STINNER Victor <vstinner@python.org> added the comment:

I like the https://docs.python.org/dev/whatsnew/3.10.html#better-error-messages section: well done, thanks ;-)

----------

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue38530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue38530] Offer suggestions on AttributeError and NameError [ In reply to ]
Change by Pablo Galindo Salgado <pablogsal@gmail.com>:


----------
pull_requests: +24173
pull_request: https://github.com/python/cpython/pull/25443

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue38530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue38530] Offer suggestions on AttributeError and NameError [ In reply to ]
Change by Pablo Galindo Salgado <pablogsal@gmail.com>:


----------
pull_requests: +24174
pull_request: https://github.com/python/cpython/pull/25444

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue38530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue38530] Offer suggestions on AttributeError and NameError [ In reply to ]
Pablo Galindo Salgado <pablogsal@gmail.com> added the comment:


New changeset 3b82cae774638ecf2baaee8fe2cac8fedafb2ca7 by Pablo Galindo in branch 'master':
bpo-38530: Properly extend UnboundLocalError from NameError (GH-25444)
https://github.com/python/cpython/commit/3b82cae774638ecf2baaee8fe2cac8fedafb2ca7


----------

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue38530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue38530] Offer suggestions on AttributeError and NameError [ In reply to ]
Pablo Galindo Salgado <pablogsal@gmail.com> added the comment:


New changeset 0ad81d4db2f409d72f469d0b74ab597be772a68e by Pablo Galindo in branch 'master':
bpo-38530: Match exactly AttributeError and NameError when offering suggestions (GH-25443)
https://github.com/python/cpython/commit/0ad81d4db2f409d72f469d0b74ab597be772a68e


----------

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue38530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue38530] Offer suggestions on AttributeError and NameError [ In reply to ]
Change by Pablo Galindo Salgado <pablogsal@gmail.com>:


----------
pull_requests: +24187
pull_request: https://github.com/python/cpython/pull/25460

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue38530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue38530] Offer suggestions on AttributeError and NameError [ In reply to ]
Pablo Galindo Salgado <pablogsal@gmail.com> added the comment:


New changeset 3ab4bea5a3ac28820781cf62a768c65370c9054c by Pablo Galindo in branch 'master':
bpo-38530: Include builtins in NameError suggestions (GH-25460)
https://github.com/python/cpython/commit/3ab4bea5a3ac28820781cf62a768c65370c9054c


----------

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue38530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue38530] Offer suggestions on AttributeError and NameError [ In reply to ]
Change by Pablo Galindo Salgado <pablogsal@gmail.com>:


----------
pull_requests: +24188
pull_request: https://github.com/python/cpython/pull/25462

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue38530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue38530] Offer suggestions on AttributeError and NameError [ In reply to ]
Pablo Galindo Salgado <pablogsal@gmail.com> added the comment:


New changeset 0b1c169c4a009e1094fe5df938d2367e63ebeea0 by Pablo Galindo in branch 'master':
bpo-38530: Cover more error paths in error suggestion functions (GH-25462)
https://github.com/python/cpython/commit/0b1c169c4a009e1094fe5df938d2367e63ebeea0


----------

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue38530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue38530] Offer suggestions on AttributeError and NameError [ In reply to ]
Change by Pablo Galindo Salgado <pablogsal@gmail.com>:


----------
pull_requests: +24201
pull_request: https://github.com/python/cpython/pull/25473

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue38530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue38530] Offer suggestions on AttributeError and NameError [ In reply to ]
Change by Dennis Sweeney <sweeney.dennis650@gmail.com>:


----------
nosy: +Dennis Sweeney
nosy_count: 8.0 -> 9.0
pull_requests: +24304
pull_request: https://github.com/python/cpython/pull/25584

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue38530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue38530] Offer suggestions on AttributeError and NameError [ In reply to ]
Dennis Sweeney <sweeney.dennis650@gmail.com> added the comment:

I opened PR 25584 to fix this current behavior:

>>> v
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'v' is not defined. Did you mean: 'id'?
>>> vv
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'vv' is not defined. Did you mean: 'id'?
>>> vvv
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'vvv' is not defined. Did you mean: 'abs'?

----------

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue38530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue38530] Offer suggestions on AttributeError and NameError [ In reply to ]
Pablo Galindo Salgado <pablogsal@gmail.com> added the comment:


New changeset 284c52da092438522949d6f96d8c1f9ff37f9f00 by Dennis Sweeney in branch 'master':
bpo-38530: Require 50% similarity in NameError and AttributeError suggestions (GH-25584)
https://github.com/python/cpython/commit/284c52da092438522949d6f96d8c1f9ff37f9f00


----------

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue38530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue38530] Offer suggestions on AttributeError and NameError [ In reply to ]
Dennis Sweeney <sweeney.dennis650@gmail.com> added the comment:

Some research of other projects:


LLVM [1][2]
-----------

- Compute Levenshtein
- Using O(n) memory rather than O(n^2)
- Uses UpperBound = (len(typo) + 2) // 3


GCC [3]
-------

- Uses Damerau-Levenshtein distance
- Counts transpositions like "abcd" <-> "bacd" as one move
- Swapping Case as in "a" <-> "A" counts as half a move
- cutoff = (longer + 2) // 3 if longer - shorter >= 2 else max(longer // 3, 1)


Rust [4]
--------

- "maximum allowable edit distance defaults to one-third of the given word."
- First checks for exact case-insensitive match, then check for Levenshtein distance small enough, then check if sorted(a.split("_")) == sorted(b.split("_"))


Ruby [5]
--------
- Quickly filter out words with bad Jaro–Winkler distance
- threshold = input.length > 3 ? 0.834 : 0.77
- Only compute Levenshtein for words that remain
- threshold = (input.length * 0.25).ceil
- Output all good enough words
- If no word was good enough then output the closest match.


I think there are some good ideas here.


[1] https://github.com/llvm/llvm-project/blob/d480f968ad8b56d3ee4a6b6df5532d485b0ad01e/llvm/include/llvm/ADT/edit_distance.h#L42
[2] https://github.com/llvm/llvm-project/blob/e2b3b89bf1ce74bf889897e0353a3e3fa93e4452/clang/lib/Sema/SemaLookup.cpp#L4263
[3] https://github.com/gcc-mirror/gcc/blob/16e2427f50c208dfe07d07f18009969502c25dc8/gcc/spellcheck.c
[4] https://github.com/rust-lang/rust/blob/673d0db5e393e9c64897005b470bfeb6d5aec61b/compiler/rustc_span/src/lev_distance.rs#L44
[5] https://github.com/ruby/ruby/blob/48b94b791997881929c739c64f95ac30f3fd0bb9/lib/did_you_mean/spell_checker.rb

----------

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue38530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue38530] Offer suggestions on AttributeError and NameError [ In reply to ]
Pablo Galindo Salgado <pablogsal@gmail.com> added the comment:

Hi Dennis, this is a fantastic investigation!

I think I really like GCC approach here. We may want to invest into porting some of their ideas into our solution.

----------

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue38530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue38530] Offer suggestions on AttributeError and NameError [ In reply to ]
Change by Dennis Sweeney <sweeney.dennis650@gmail.com>:


----------
pull_requests: +24466
pull_request: https://github.com/python/cpython/pull/25776

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue38530>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

1 2  View All