-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Automatically respect .pylintrc files in subdirectories #442
Comments
@MikhailArkhipov Was this supposed to be included in release 2018.3.0 (28 Mar 2018)? Because I have just downloaded that version and it does not seem to work? The Problems view still shows the pylint errors that should not be seen du to a .pylintrc int he same directory as the file being linted. |
Can you attach the file and tell which errors are showing up? |
What happens when you run pylint from command line on that file from the folder the file is in? |
@MikhailArkhipov Could this in any way be related to that I run on Windows? Maybe a similar issue such as this? pylint-dev/pylint#1941 It works just fine running from command line:
|
I use Windows too mostly. You are specifying pylintrc file location explicitly. Can you try running pylint from the file folder without |
|
@MikhailArkhipov We're doing this with the formatters today, for the same reason. |
@MikhailArkhipov Any progress on this? :) It kind of died. |
@thernstig it's currently scheduled for our April release so this has not been forgotten (we're just really swamped with things ATM). |
Current behavior is not a bug. The extension have been running pylint from the workspace root for quite some time Running pylint from the file folder would prevent it from finding pylintrc at the workspace root. Pylint does not walk up the tree in all cases. See https://github.com/PyCQA/pylint/blob/975e08148c0faa79958b459303c47be1a2e1500a/pylint/config.py
So changing cwd would be significant change in the linting behavior. One possibility is to run it from file folder AND supplying path to .pylintrc if it exists at the workspace root. |
@brettcannon Did this fell out and is not planned for any milestone? The issue has a few upvotes so I assume it is popular in some sense. :) |
@MikhailArkhipov I just read your comment and I have a question about this part:
I am not sure how to interpret this.
I am most likely missing something. If I am not, then as I read it, if you run Pylint from the file folder it will eventually traverse upwards to find the .pylintrc in the root folder. |
If someone wanted to come up with a PR to support running Pylint in the directory that the code being analyzed is in then we would be happy to review it, but right now this isn't a priority due to other work taking up our time. |
I found this bug in VSCode, then found this bug report. In my case, I have a folder (~/work/git) that is opened in vscode with a bunch of sub-directories (separate git repositories). One of these had a .pylintrc added to it. In theory, it's the same as what VSCode was using for linting. It was added so that our CI system could run pylint with those settings. As per this bug, VSCode is not using that .pylintrc but what I'm seeing is that VSCode isn't even using it's default pylint settings either. As a result, I am seeing extra pylint warnings and a heap of pylint infos. If I remove the .pylintrc, the extra warnings/infos go away. Luckily, I don't want extra pylint stuff, just the standard VSCode rules running over everything, so I'm able to copy the file to ~/work/git to work around the bug. Version: 1.40.0 |
I'd suggest to use @JamesMessinger solution, atleast your workspace will find the |
This is surprising behavior! Especially in larger repositories or monorepos, it's likely that different pylint standards will be applied to different parts of the directory tree or even to submodules. For example, you might want to enforce the existence of module-level docstrings in a library, but not in test files. |
This still seems like a pretty significant change from the current linting behaviour. And also pretty arbitrary. Because pylint doesn't just get its configuration from I think a good compromise would just be adding a boolean setting for the extension that tells it whether or not to run the linting in file's directory or the workspace directory. This would also be useful for other linters like Thoughts? |
Not to mention that pylint for some reason produces different linting decisions for its import ordering depending on which directory you call it from, regardless of any configuration you provide it. Which is fun. I think it is probably best to keep current behaviour, and put this enhancment behind a setting imo. |
I face a similar problem with our own linter and we decided to not allow more than one configuration file. There is no good way to fix the problem of multiple config files, especially in the context of partial or live linting in LS style. I would recommend a very different path here: making the multi-configuration a warning in the two tools that support it, basically deprecating it. I would support that and probably it is an easier way for everyone. Regarding the config location, it should be up to the tool (linter) itsel to be able to report it, so the LS would even need to know where it is stored. I do not think that we need UI features for editing linter own settings, just the on/off. |
The pre-release version of |
I have now gone Ruff instead 😄 |
@thernstig |
Environment data
VS Code version: 1.19.0
Python Extension version: 0.9.0 (14 December 2017)
Python Version: 3.6.1
OS and version: Windows 10 Home, Version 1703, OS-version 15063.483
Actual behavior
.pylintrc files in a directory in the workspace are not automatically found by pylint
Expected behavior
This is how it works when running the pylint command via terminal. .pylintrc files are automatically respected without supplying them specifically via the option
--rcfile
Note that I am unsure if other options are respected as defined here
https://pylint.readthedocs.io/en/latest/user_guide/run.html#command-line-options
Steps to reproduce:
The text was updated successfully, but these errors were encountered: