Skip to content

epylint not able to parse a .pylintrc file in a subdirectory on Windows #1940

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
thernstig opened this issue Mar 15, 2018 · 1 comment
Closed

Comments

@thernstig
Copy link
Contributor

Steps to reproduce

  1. Add this to a file called test.py
''' Script to lint all code e.g. python '''
import os
from pylint import epylint

def lint_pylint():
    ''' Lint all python code with pylint '''
    pylintrc = os.path.join("afolder", ".pylintrc")
    epylint.py_run(f'afolder -j 0 --rcfile={pylintrc}')

if __name__ == "__main__":
    lint_pylint()
  1. Add a .pylintrc in a directory like: afolder/.pylintrc
  2. Run test.py

Current behavior

It cannot handle .pylintrc files on Windows not in the same folder as the command being run. You thus get an error like:

(venv) ~\Desktop\projects\test [master]> python .\test.py
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\Moo\Desktop\projects\test\venv\lib\site-packages\pylint\lint.py", line 1301, in __init__
    linter.read_config_file()
  File "C:\Users\Moo\Desktop\projects\test\venv\lib\site-packages\pylint\config.py", line 646, in read_config_file
    raise IOError("The config file {:s} doesn't exist!".format(config_file))
OSError: The config file afolder.pylintrc doesn't exist!

Expected behavior

For it to work. The problem can be found in how shlex.split is invoked on Windows. The line here https://github.com/PyCQA/pylint/blob/9dd978aaed0daf852d8caed515b9e4e13f2dfcc7/pylint/epylint.py#L142 could be changed to:

options = shlex.split(command_options, posix='win' not in sys.platform)

pylint --version output

(venv) ~\Desktop\projects\test [master]> pylint --version
No config file found, using default configuration
pylint 1.8.2,
astroid 1.6.1
Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit (AMD64)
@thernstig
Copy link
Contributor Author

I will have a merge request incoming any second.

PCManticore pushed a commit that referenced this issue Mar 16, 2018
* Fix shlex parsing error on Windows in epylint

Closes #1940

* Change py_run's shlex posix sys.platform

sys.platform mistakenly included darwin as not posix compliant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant