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

Add support for pyproject.toml as pylint config file #107

Merged
merged 1 commit into from
Feb 10, 2020

Conversation

michael-k
Copy link
Contributor

pylint 2.5 (unreleased) can read its config also from pyproject.toml and setup.cfg. See pylint-dev/pylint#3169 for details.

This PR adds support forpyproject.toml.

pytest_pylint.py Outdated

def _load_pyproject_toml(session, pylintrc_file):
with open(pylintrc_file, "r") as f_p:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

With f or fp instead of f_p:

C:153,37: Variable name "f" doesn't conform to snake_case naming style (invalid-name)

@@ -20,7 +20,7 @@
py_modules=['pytest_pylint'],
entry_points={'pytest11': ['pylint = pytest_pylint']},
python_requires=">=3.5",
install_requires=['pytest>=5.0', 'pylint>=2.0.0'],
install_requires=['pytest>=5.0', 'pylint>=2.0.0', 'toml>=0.7.1'],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same lower bound as pylint.

"""Verify that pyproject.toml can be used as a pylint rc file."""
rcfile = testdir.makefile('.toml', """
[tool.pylint.FORMAT]
max-line-length = "3"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

With 3 instead of "3", toml loads it as an integer and not a string and breaks pylint. This might change in the future.

elif rcformat == "simple_toml":
rcfile = testdir.makefile('toml', """
[tool.pylint.MASTER]
ignore = "test_pylintrc_ignore.py,foo.py"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

toml has support for lists, see a few lines above. pylint however does not support them yet. See pylint-dev/pylint#617 (comment) and following comments.

Since pytest-pylint handles the ignores, we can use lists, but should also support the old format to keep switches from pylint to pytest-pylint and back simple.

rcformat toml vs simple_toml also tests [tool.pylint.master] vs [tool.pylint.MASTER]. pylint supports both, see pylint-dev/pylint#617 (comment).

@@ -9,6 +9,7 @@ deps =
pytest-pep8
coverage
mock
https://github.com/PyCQA/pylint/archive/master.tar.gz
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is necessary until pylint 2.5 is released.

@carsongee
Copy link
Owner

carsongee commented Feb 10, 2020

Hey, @michael-k this looks great, and thank you for the contribution. Sorry for the delay in getting back to you. I'm back from an open source hiatus, and did some refactoring of this repo tonight. Could you rebase? I just moved the monolithic file into multiple files and got rid of the session namespace pollution I was doing to replace it with class properties, so it shouldn't be too hard to move this code in. Thanks again!

@michael-k
Copy link
Contributor Author

Could you rebase?

done :)

@carsongee carsongee merged commit 965460c into carsongee:master Feb 10, 2020
@michael-k michael-k deleted the pyproject.toml branch February 10, 2020 16:05
michael-k added a commit to michael-k/awesome-pyproject that referenced this pull request Feb 11, 2020
carsongee pushed a commit that referenced this pull request Mar 5, 2020
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.

2 participants