Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
relative imports/includes fail when linting #1175
Let is consider sample FooBar module in Python
with some relative imports.
Steps to Reproduce
No errors in import,
Ln: 7, pylint: E0401 Unable to import '#iw6prl.foo2' (ERROR)
Komodo Edit or IDE?
Looks like the problem Komodo run pylint on some temporary file somewhere,
I hope the problem should be finally fixed (I am tired to set "pylint: disable" for every relative import).
-- eg. Error logs, screenshots, workarounds --
This will affect any linter that supports relative imports.
Seems we may finally have a test case for #14
@belonesox could you comment on Todd's statement?
Thank you, but I should note that this is only workaround, such way can not handle relative wildcard imports, and "Komodo pylint" will raise errors like that:
( https://github.com/belonesox/foobarpy/blob/master/mods/foom/foom2.py, syntaxically correct, OK for pylint running on same directory )
(That weird module name is the name of the temporary file.)
If I run Pylint directly on the file in its directory, I get the expected results. However, none of our linters run directly on files -- they always create temporary files and lint those. I'm not sure of the ramifications if we linted files (or at least Python files) directly. @Naatan what do you think?
Ramifications I can think of:
I would suggest adding a pref that lets people say "save temp linting files in the same directory", but given the miniscule amount of people that actually customize these prefs I'm not convinced this is worth the effort.
I'd imagine we could address this more intelligently if and when we write our own linters?
While we'd have more control over this if we wrote our own linters, it would likely be a big undertaking.
I think at this point we can conclude there is no way of catching every case of relative imports. So far it looks like we only cannot handle wildcard relative imports. I'd recommend just putting