Hi all,

I'm currently using Phabricator's Arcanist to run PyLint. The way Arcanist
works is when you run 'arc lint', it finds all of the files your current
change in your repo has touched, and passes each of them off to PyLint as
separate invocations. The default invocation of PyLint looks like this:

pylint -rn -iy /full/path/to/source/file

Notably, Arcanist runs with the root of my source repository as the CWD.
The way we've set up our repository, there are a number of subprojects in
this source repo. So, for concreteness of example, let's say my source repo
is

/home/jt/repo/

and I have a source file at

/home/jt/repo/project/main.py

that imports utils from the lib module:

/home/jt/repo/project/lib/__init__.py
/home/jt/repo/project/lib/utils.py

Notice that PyLint is going to be run on the main.py file like this (note
the CWD):

/home/jt/repo$ pylint -rn -iy /home/jt/repos/project/main.py

PyLint complains because it can't find module 'lib'.

I dug into the PyLint source, and it's doing a thing where for the file
being linted, it adds the CWD to the PYTHONPATH. So, where Python expects
/home/jt/repos/project/ to be part of the PYTHONPATH (or sys.path, as it
is), PyLint provides /home/jt/repos/ as part of the PYTHONPATH, and NOT
/home/jt/repos/project/

This does not match Python's import directory resolution behavior, and has
caused us a considerable headache. I'd like to lint my source files as
Python runs them, not as Pylint does. What would it take to change this
behavior upstream?

-JT
_______________________________________________
Python-Projects mailing list
[email protected]
http://lists.logilab.org/mailman/listinfo/python-projects

Reply via email to