pylint icon indicating copy to clipboard operation
pylint copied to clipboard

allow-any-import-level seems to have no effect

Open paugier opened this issue 1 year ago • 1 comments

Bug description

I try to use allow-any-import-level but it does not seem to have any effect.

With a module with:

MY_CONST = 1
import numpy
print(numpy)

pylint mod.py --allow-any-import-level numpy produces the error message:

mod.py:7:0: C0413: Import "import numpy" should be placed at the top of the module (wrong-import-position)

I tried with a configuration file and with different variations of the command but I didn't manage to correctly use allow-any-import-level.

Command used

pylint mod.py --allow-any-import-level numpy

Pylint output

mod.py:7:0: C0413: Import "import numpy" should be placed at the top of the module (wrong-import-position)

Expected behavior

No message C0413 for numpy imports.

Pylint version

pylint 3.0.3
astroid 3.0.3
Python 3.9.2 (default, Feb 28 2021, 17:03:44) 
[GCC 10.2.1 20210110]

OS / Environment

Linux

Additional dependencies

No response

paugier avatar Feb 23 '24 11:02 paugier

Thanks @paugier!

allow-any-import-level doesn't supress wrong-import-position; it suppresses import-outside-toplevel.

Is there a way we can improve the situation via the documentation?

mbyrnepr2 avatar May 17 '24 20:05 mbyrnepr2