-
Notifications
You must be signed in to change notification settings - Fork 1
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
Include an option to use ruff as the linter #188
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,90 @@ filterwarnings = [ | |
{% endif %} | ||
] | ||
|
||
{% if cookiecutter.get("linter") == "ruff" %} | ||
[tool.ruff] | ||
target-version = "py311" | ||
line-length = 88 | ||
exclude = [ | ||
"tests/bdd/steps/_compiled_feature_steps.py", | ||
] | ||
|
||
[tool.ruff.lint] | ||
select = [ | ||
"E", "W", # https://docs.astral.sh/ruff/rules/#pycodestyle-e-w | ||
"D", # https://docs.astral.sh/ruff/rules/#pydocstyle-d | ||
"ARG", # https://docs.astral.sh/ruff/rules/#flake8-unused-arguments-arg | ||
"BLE001", # https://docs.astral.sh/ruff/rules/blind-except/ | ||
"R", "PLR", # https://docs.astral.sh/ruff/rules/#refactor-r | ||
"C", "PLC", # https://docs.astral.sh/ruff/rules/#convention-c | ||
"SLF", # flake-8-self | ||
"N", # https://docs.astral.sh/ruff/rules/#pep8-naming-n | ||
"F", # https://docs.astral.sh/ruff/rules/unused-import/ | ||
|
||
"RUF100", # unused-noqa | ||
] | ||
|
||
ignore = [ | ||
# Missing docstrings. | ||
"D100","D101","D102","D103","D104","D105","D106","D107", | ||
|
||
# "No blank lines allowed after function docstring" conflicts with the | ||
# Black code formatter which insists on inserting blank lines after | ||
# function docstrings. | ||
"D202", | ||
|
||
# "1 blank line required before class docstring" conflicts with another | ||
# pydocstyle rule D211 "No blank lines allowed before class docstring". | ||
"D203", | ||
|
||
# "Multi-line docstring summary should start at the first line" | ||
# and "Multi-line docstring summary should start at the second line". | ||
# These two rules conflict with each other so you have to disable one of them. | ||
# How about we disable them both? PEP 257 says either approach is okay: | ||
# | ||
# > The summary line may be on the same line as the opening quotes or on | ||
# > the next line. | ||
# > | ||
# > https://peps.python.org/pep-0257/#multi-line-docstrings | ||
"D212", | ||
"D213", | ||
|
||
# We use Black to format our code automatically, so we don't need PyLint to | ||
# check formatting for us. | ||
"E501", # line-too-long | ||
|
||
"PLR2004", # Magic values, we mostly get it on HTTP status codes | ||
|
||
# Disabled during the pylint migration, ideally we'll enable this after we are settled in ruff | ||
"RET504", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Having these here allows to remove them from the template and apply to all projects. |
||
"RET501", | ||
"PLR6301", | ||
] | ||
|
||
[tool.ruff.lint.per-file-ignores] | ||
"tests/*" = [ | ||
# Just disable name style checking for the tests, because we | ||
# frequently use lots of argument names that don't conform. | ||
# For example we frequently create pytest fixtures that aren't named in | ||
# snake_case, such as a fixture that returns a mock of the FooBar class would | ||
# be named FooBar in CamelCase. | ||
"N", | ||
# We are more lax about comment formatting in the tests | ||
"D", | ||
|
||
"PLR0913", | ||
|
||
# Lots of test methods don't use self, but we still want to group our tests | ||
# into classes. | ||
"PLR6301", | ||
|
||
"PLR0917", # too-many-arguments | ||
"PLC2701", # private import | ||
"PLR0904", # too-many-public-methods | ||
] | ||
# Ignore unused import errors on __init__ files to avoid having to add either a noqa stament or an __all__ declaration. | ||
"__init__.py" = ["F401"] | ||
{% else %} | ||
[tool.pydocstyle] | ||
ignore = [ | ||
# Missing docstrings. | ||
|
@@ -89,6 +173,7 @@ ignore = [ | |
{{ include("pydocstyle/ignores", indent=4) -}} | ||
{% endif %} | ||
] | ||
{% endif %} | ||
|
||
[tool.coverage.run] | ||
branch = true | ||
|
@@ -127,6 +212,7 @@ exclude_also = [ | |
{% endif %} | ||
] | ||
|
||
{% if cookiecutter.get("linter") != "ruff" %} | ||
[tool.isort] | ||
multi_line_output = 3 | ||
include_trailing_comma = true | ||
|
@@ -221,6 +307,7 @@ good-names = [ | |
[tool.pylint.reports] | ||
output-format = "colorized" | ||
score = "no" | ||
{% endif %} | ||
|
||
[tool.mypy] | ||
allow_untyped_globals = true | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
pip-tools | ||
pip-sync-faster | ||
{% if cookiecutter.get("linter") == "ruff" %} | ||
ruff | ||
{% else %} | ||
black | ||
isort | ||
{% endif %} | ||
{% if include_exists("requirements/checkformatting.in") %} | ||
{{- include("requirements/checkformatting.in") -}} | ||
{% endif %} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
pip-tools | ||
pip-sync-faster | ||
{% if cookiecutter.get("linter") == "ruff" %} | ||
ruff | ||
{% else %} | ||
black | ||
isort | ||
{% endif %} | ||
{% if include_exists("requirements/format.in") %} | ||
{{- include("requirements/format.in") -}} | ||
{% endif %} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ruff config is more compact, no need for two files, remove the test one in case is generated.