-
Notifications
You must be signed in to change notification settings - Fork 48
Relative imports not working (Django) #110
Comments
I am also experiencing this problem. It doesn't seem specific to Django. |
Same to me. Sadly I can't figure out after which version the problem appeared. |
If I had to guess this is a problem with the $PYTHONPATH hackery going on, but I have no idea @AtomLinter/linter-pylint any pointers as to how to debug this? |
So, after an investigation seems like the problem depends of pylint version. Since version 1.5.0 all relative imports in my projects are recognized as errors (using this linter).
I've reproduced manually this scenario and with pylint>=1.5.0 I'm receiving import errors.
The problem is that I'm using pylint-django which has some issues with pylint<1.5.0. So, I can't just downgrade pylint. Are you doing that magic with PYTHONPATH and temporary file to lint on the fly? |
If I remember that stuff was added to enable people to work around not running Atom in the proper virtualenv, but you'd have to ask @SpainTrain on that as I believe he is the author of that bit. |
Ok, I'm still running in to this issue in atom-pylint v1.2.2. And I'm not using Django. And it has everything to do with the fact that atom-pylint creates a tempFile out of the text that is in the editor and then runs pylint against that new tempFile. And as you would expect with any temp file, it is in a completely different and ambiguous directory. And when pylint inspects this temp file and it comes across a line So, can I propose a fix of maybe making the tempfile that gets written stay in the same directory with the actual file? |
Not specific to Django - please update the issue title. As far as I can see, any relative import of the following form is failing: from .module import thing Using https://github.com/Horta/linter-py fixes the issue @horta: any chance of merging your changes back? |
Hi @sneakypete81 Also, it might be possible to solve this problem via linter-pylint itself. I will post here back in a couple of hours! |
I want to use linter-pylint in atom, but I have some problems with relative imports.
For example, in
tests.py
I want to import a django modelPylint wants to import
tests.models
. If I run pylint from command line it works properly.The text was updated successfully, but these errors were encountered: