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

feat: auto-find config that is not pylintrc based #156

Merged
merged 7 commits into from
Aug 11, 2021

Conversation

bennyrowland
Copy link

Changes the way that the config file is retrieved from pylint.config. Previously
this was done using the static variable pylint.config.PYLINTRC which is defined
at load by iterating over all the files found via
pylint.config.find_default_config_files() until one ending in "pylintrc" is
found. In pylint itself config seems instead to be found by calling
next(find_default_config_files(), None) which is also able to find setup.cfg or
pyproject.toml based config files automatically. I have thus changed PyLintPlugin
to use the same version and can now call py.test --pylint and have config from
my pyproject.toml picked up correctly.

I have added one additional test, essentially copying the existing
test_pylint_file_toml, but now called test_pyline_file_pyproject_toml, which
is modified to name the config file pyproject.toml and does not pass the
--pyline-fcfile option but expects it to be auto-detected. This test passes
when the file is called pyproject.toml but fails when it is called something
different.

Ben Rowland added 7 commits May 10, 2021 13:31
Changes the way that the config file is retrieved from pylint.config. Previously
this was done using the static `variable pylint.config.PYLINTRC` which is defined
at load by iterating over all the files found via
`pylint.config.find_default_config_files()` until one ending in "pylintrc" is
found. In pylint itself config seems instead to be found by calling
`next(find_default_config_files(), None)` which is also able to find setup.cfg or
pyproject.toml based config files automatically. I have thus changed PyLintPlugin
to use the same version and can now call `py.test --pylint` and have config from
my pyproject.toml picked up correctly.

I have added one additional test, essentially copying the existing
`test_pylint_file_toml`, but now called `test_pyline_file_pyproject_toml`, which
is modified to name the config file `pyproject.toml` and does not pass the
`--pyline-fcfile` option but expects it to be auto-detected. This test passes
when the file is called pyproject.toml but fails when it is called something
different.
…is being

used and there is no support for pyproject.toml etc.
… file but

still ran the test that would fail when it couldn't detect the file. this
should fix that. I also had to modify the test invalidate_cache_when_config_changes
as autofinding the config caused that test to fail (which I assume was not
intended)
…figured,

not at load time of the module which may have been affecting things. Also
made a change to the import of pylint.config to comply with isort and
pylint 2.3
@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 98.646% when pulling 8f4d66b on bennyrowland:auto_find_config into d9f2776 on carsongee:main.

@coveralls
Copy link

coveralls commented May 10, 2021

Coverage Status

Coverage increased (+0.05%) to 98.627% when pulling 8f4d66b on bennyrowland:auto_find_config into d9f2776 on carsongee:main.

@bennyrowland
Copy link
Author

Sorry for the string of commits, it took me a while to figure out how to get all the different version of pylint to be happy with the code. I also found that some tests passed on my dev machine but not on travis for an earlier version of the code - to fix that I had to move the search for the config file into the plugin pytest_configure() method, to make sure it picks up on the change in path. Hopefully you agree that this is a useful feature of the plugin, I certainly like being able to drop the extra command line argument.

Copy link
Owner

@carsongee carsongee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks you for this great enhancement! I'm sorry I missed it earlier😬

@carsongee carsongee merged commit e3e96a0 into carsongee:main Aug 11, 2021
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

Successfully merging this pull request may close these issues.

3 participants