[New-bugs-announce] [issue46902] Typo hint message for from-imports?

Jean Abou Samra report at bugs.python.org
Wed Mar 2 15:42:20 EST 2022


New submission from Jean Abou Samra <jean at abou-samra.fr>:

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'?

----------
components: Interpreter Core
messages: 414385
nosy: Jean_Abou_Samra
priority: normal
severity: normal
status: open
title: Typo hint message for from-imports?
type: enhancement
versions: Python 3.10, Python 3.11

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46902>
_______________________________________


More information about the New-bugs-announce mailing list