Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Make %p python path default #67

Closed
merlijn-sebrechts opened this issue Sep 14, 2015 · 8 comments
Closed

Make %p python path default #67

merlijn-sebrechts opened this issue Sep 14, 2015 · 8 comments

Comments

@merlijn-sebrechts
Copy link

Steps to reproduce:

  1. Write python script that uses module in same folder.
  2. Check errors
  3. Try to run the code

What I get:

  • Code runs fine
  • Linter gives error

What I expect:

  • Code runs fine
  • Linter gives no error

The default module searching behavior of the linter should be the same as that of Python itself. This is currently not the case, since %p is not added to the path. Is there a reason for this?

@merlijn-sebrechts
Copy link
Author

related: #58

@SpainTrain
Copy link
Member

Write python script that uses module in same folder.

You are talking about relative imports right? A fully qualified import should work. As you saw, relative imports are reported in #58 and fixed in the soon-to-be merged #61.

since %p is not added to the path

For context, the project directory (%p) is added to the path (https://github.com/AtomLinter/linter-pylint/blob/master/lib/main.coffee#L69). This is why the fully qualified/absolute import should work (and please open another issue if not!). However, the problem is that this isn't sufficient to mirror the behavior of module searching in Python. #61 sufficiently mirrors the behavior and I'll see to getting it merged/released soon!

@merlijn-sebrechts
Copy link
Author

I have a hard time understanding whether I am doing something wrong or there is a bug. My knowledge about Python and Atom isn't much and Atom has a very confusing definition of what a project is (+ you have "project home" setting, which doesn't have to do with "projects" aka "the folder you have open"..?)

Let my try to explain what I expect to happen: I have two files in one directory. The test directory is the root directory that is open in atom.

test
|- importer.py
|- tester.py

tester.py:

def test1():
    print "test1"

importer.py:

#!/usr/bin/python
import tester
tester.test1()

When I execute importer.py I see 'test1", so it works. However, I still get the error F0401 Unable to import tester in Atom.

I have no idea if this is a relative or absolute import, since those terms are mostly used when talking about packages. I do not think this is considered a package, just two files in the same directory. The import is "absolute" compared to the project directory (if "project directory" means "root directory in atom"?)...

I'm sorry for my lack of understanding, but a lot of the terms used here have confusing/implicit definitions. Feel free to explain them for me...

@SpainTrain
Copy link
Member

Ok, I see now. This is different than #58, but I think that #61 may still actually fix this issue as well. We will leave this issue open and see whether #61 manages to fix it.

@SpainTrain SpainTrain added the bug label Sep 15, 2015
@miigotu
Copy link
Contributor

miigotu commented Sep 20, 2015

#61 Does not fix the import problems for me. Ive tried a whole mess of different paths in the "Python Path" setting in linter-python settings and nada, still F0401

@romanchyla
Copy link

I think you should consider the negative consequences of messing with PYTHONPATH: #104

@miigotu
Copy link
Contributor

miigotu commented Apr 29, 2016

Still messed up for me too. No matter what I put in the pythonpath setting I get F0401 for any imports not coming from site-packages. pylint on the command line does not give this error.

Im going to try and patch my local copy and see if I can fix it, its super annoying. Im not even using any custom sys.path

@Arcanemagus
Copy link
Member

I'm marking this as a duplicate of #58 since the root cause is the same, even if the steps to reproduce aren't exactly the same (just almost the same...).

More explanation soon to be posted over there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants