False positive import-self
when attempting relative import of misspelled submodule name in a package.
#7452
Labels
import-self
when attempting relative import of misspelled submodule name in a package.
#7452
Bug description
from . import <submodule-name>
is a frequent pattern in Python and people can misspell a submodule name. As the misspelled name should not conflict with any attribute contained in the module performing the relative import, an error about a missing module attribute would be more appropriate and less likely to produce confusion thanimport-self
. It seems reasonable thatimport-self
should be reserved for cases where there is an attempt to import an existent attribute from the importing module itself.Result of running Pylint on this:
I see that there has been some recent conversation around another
import-self
issue: #5151 / #7289 . If a fix for this issue is also part of the fix for that one, then apologies for the noise.Configuration
No response
Command used
Pylint output
************* Module pylint_bug pylint_bug/__init__.py 2, 0 [import-self] Module import itself
Expected behavior
Would expect an error about a missing module attribute. Would only expect to see
import-self
if the module attribute actually existed and the module had an import cycle with itself.Pylint version
OS / Environment
No response
Additional dependencies
No response
The text was updated successfully, but these errors were encountered: