This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Typo hint message for from-imports?
Type: enhancement Stage:
Components: Interpreter Core Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Jean_Abou_Samra, aroberge, pablogsal
Priority: normal Keywords:

Created on 2022-03-02 20:42 by Jean_Abou_Samra, last changed 2022-04-11 14:59 by admin.

Messages (2)
msg414385 - (view) Author: Jean Abou Samra (Jean_Abou_Samra) * Date: 2022-03-02 20:42
See for example:

>>> from pygments.regexopt import regexopt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'regexopt' from 'pygments.regexopt' (/home/jean/repos/pygments/pygments/regexopt.py)
>>> from pygments.regexopt import regex_opt
>>> regexopt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'regexopt' is not defined. Did you mean: 'regex_opt'?

In Python 3.10, there is a nice helpful error message suggesting
how to correct the typo for NameError and AttributeError. Would
it be possible to have the same for ImportError with 'from import'?
msg414398 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2022-03-03 01:54
I evaluated this, but is considerably more complex than the regular import, because one triggers an attribute error where we have the full module but in the second case we don't have the full module ready, so it requires considerable modifications.

I will investigate again if there is a way that doesn't require lots of changes, but is likely that we unfortunately need to reject this improvement :(
History
Date User Action Args
2022-04-11 14:59:56adminsetgithub: 91058
2022-03-03 01:54:35pablogsalsetmessages: + msg414398
2022-03-03 01:09:36arobergesetnosy: + aroberge
2022-03-02 21:54:55AlexWaygoodsetnosy: + pablogsal

versions: - Python 3.10
2022-03-02 20:42:20Jean_Abou_Samracreate