Skip to content
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

Disable pylintUseMinimalCheckers when local pylint config exists #788

Closed
patrys opened this issue Feb 15, 2018 · 5 comments · Fixed by #805
Closed

Disable pylintUseMinimalCheckers when local pylint config exists #788

patrys opened this issue Feb 15, 2018 · 5 comments · Fixed by #805
Assignees
Labels
area-linting bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster
Milestone

Comments

@patrys
Copy link

patrys commented Feb 15, 2018

I understand that it makes sense to hide some errors by default but if a project explicitly configures the linter then I think the editor should not override local choices. I am specifically talking about cases where one of the following is true:

  • .pylintrc exists
  • pylintrc exists
  • PYLINTRC environment variable is set and points to an existing file
  • pylintArgs setting is customized
@DonJayamanne DonJayamanne added bug Issue identified by VS Code Team member as probable bug area-linting awaiting 2-PR labels Feb 15, 2018
@MikhailArkhipov
Copy link

It should become disabled. See https://github.com/Microsoft/vscode-python/blob/master/src/client/linters/pylint.ts, hasConfigurationFile. Logic copied from pylint itself. Can you provide repro when it doesn't?

@MikhailArkhipov MikhailArkhipov self-assigned this Feb 15, 2018
@MikhailArkhipov MikhailArkhipov added the info-needed Issue requires more information from poster label Feb 15, 2018
@parkerd
Copy link

parkerd commented Feb 15, 2018

There's a faulty assumption at https://github.com/Microsoft/vscode-python/blob/master/src/client/linters/pylint.ts#L82-L84 that the directory should have __init__.py, which generally won't be true if .pylintrc is at the root of a repo.

For reference, this is the relevant logic in pylint: https://github.com/PyCQA/pylint/blob/master/pylint/config.py#L106-L113 . It will look .. one directory from the last __init__.py, instead of leaving the loop when there is none.

@MikhailArkhipov
Copy link

Makes sense. Thank you.

@MikhailArkhipov
Copy link

MikhailArkhipov commented Feb 16, 2018

The assumption was based on

def find_pylintrc():
...
        curdir = os.path.abspath(os.getcwd())
        while os.path.isfile(os.path.join(curdir, '__init__.py')):
            curdir = os.path.abspath(os.path.join(curdir, '..'))
            if os.path.isfile(os.path.join(curdir, 'pylintrc')):
                return os.path.join(curdir, 'pylintrc')
            if os.path.isfile(os.path.join(curdir, '.pylintrc')):
                return os.path.join(curdir, '.pylintrc')

which appears to only walk up the tree if __init.py__ is present...

https://pylint.readthedocs.io/en/latest/user_guide/run.html#command-line-options

You can specify a configuration file on the command line using the --rcfile option. Otherwise, Pylint searches for a configuration file in the following order and uses the first one it finds:

  1. pylintrc in the current working directory
  2. .pylintrc in the current working directory
  3. If the current working directory is in a Python module, Pylint searches up the hierarchy of Python modules until it finds a pylintrc file. This allows you to specify coding standards on a module-by-module basis. Of course, a directory is judged to be a Python module if it contains an __init__.py file.
  4. The file named by environment variable PYLINTRC
  5. if you have a home directory which isn’t /root:
    a.pylintrc in your home directory
    b. config/pylintrc in your home directory
  6. /etc/pylintrc

@MikhailArkhipov
Copy link

Actual problem is that check for the config file happens before run and then run changes current working directory to the workspace root.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-linting bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants