Use pylint config parser for pyproject.toml and setup.cfg support#14
Open
kevinoid wants to merge 4 commits into
Open
Use pylint config parser for pyproject.toml and setup.cfg support#14kevinoid wants to merge 4 commits into
kevinoid wants to merge 4 commits into
Conversation
Author
|
For reference, the test failures don't appear to be related to this PR (since it doesn't change |
833123c to
360b261
Compare
Owner
|
Sorry about that @kevinoid. Master has been fixed and tests are passing once again. |
11115e5 to
8431ded
Compare
Copy `Runner.DEFAULT_ARGS` to `self.args` so that if/when `self.args` is modified it will not affect `Runner.DEFAULT_ARGS`. Fix the tests as a result of the change: 1. Increase `max-line-length` in `tests/tests/good_rc_file` so that when it is used in `test_rcparser_success` the lint succeeds. 2. Fix `expected` in `test_passthrough_args` to not expect args to have been modified by previous tests. Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Pylint 2.5.0 and later support reading configuration from `pyproject.toml` or `setup.cfg` if `pylintrc` and `.pylintrc` do not exist. (pylint-dev/pylint#3169) In order to support these configuration files, use `pylint.lint.pylinter.PyLinter#read_config_file()` instead of `configparser.ConfigParser#read()` to read the pylint configuration. Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
If the `ignore` option is not configured, pylint_runner dies with:
configparser.NoOptionError: No option 'ignore' in section: 'MASTER'
Avoid this by checking that the option is present using `#has_option()`
before `#get()`. (Note: It is not necessary to check that the `MASTER`
section exists, since `#has_option()` returns `False` in that case.)
Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
`pylint.lint.pylinter.PyLinter#set_option()` ultimately calls `pylint.utils.utils._splitstrip()` to parse options of type `csv`, such as `ignore`. In addition to removing empty values, `_splitstrip()` strips whitespace from values. Update `ignore` parsing to behave the same as pylint. Note: Since `_splitstrip()` is private and has a simple implementation, it is inlined here. Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
8431ded to
7bcd439
Compare
Author
|
No worries. Thanks for the quick fix @MasterOdin! It should pass the CI tests now. I added an additional commit to avoid modifying |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pylint 2.5.0 and later support reading configuration from
pyproject.tomlorsetup.cfgifpylintrcand.pylintrcdo not exist. (pylint-dev/pylint#3169) In order to support these configuration files, this PR changes pylint_runner to usepylint.lint.pylinter.PyLinter#read_config_file()instead ofconfigparser.ConfigParser#read()to read the pylint configuration.It also adds a check to avoid
configparser.NoOptionErrorifignoreis not configured and to strip whitespace fromignorevalues as pylint does. If you would prefer these to be moved to a separate PR, let me know.Thanks,
Kevin