Skip to content

Commit

Permalink
Ruff, linter dependencies, full check config
Browse files Browse the repository at this point in the history
By default, the command `darker` now runs Black on the source code of
Darker, the Darker GitHub Action, release tooling and `setup.py`.

`--config=check-darker.toml` can now be used to run Flake8, Mypy,
Pydocstyle, Pylint and Ruff on modified lines in above mentioned files.
Those tools are included when installing with the `[test]` extra.

The minimum ruff version is now 0.0.292, and its configuration in
`pyproject.toml` has been updated accordingly.
  • Loading branch information
akaihola committed Mar 11, 2024
1 parent 628c8c5 commit acb6225
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
33 changes: 33 additions & 0 deletions check-darker.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This is the Darker configuration file for running all the code formatters and linters
# on the Darker code base. To use it, run:
# $ darker --config=check-darker.toml

[tool.black]
# Darker makes Black read its configuration from the file indicated by the `--config`
# option, so we need to mirror the same configuration here and in `pyproject.toml`.
skip-string-normalization = false
target-version = ["py311"]

[tool.isort]
# Darker makes isort read its configuration from the file indicated by the `--config`
# option, so we need to mirror the same configuration here and in `pyproject.toml`.
profile = "black"
known_first_party = ["darkgraylib", "graylint"]
known_third_party = ["pytest"]

[tool.darker]
src = [
"action",
"release_tools",
"src",
"setup.py",
]
revision = "origin/master..."
isort = true
lint = [
"flake8",
"mypy",
"pydocstyle",
"pylint",
"ruff check",
]
30 changes: 30 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,52 @@
requires = ["setuptools", "wheel"] # PEP 508 specifications.

[tool.black]
# Darker makes Black read its configuration from the file indicated by the `--config`
# option, so we need to mirror the same configuration here and in `check-darker.toml`.
skip-string-normalization = false
target-version = ["py311"]

[tool.isort]
# Darker makes isort read its configuration from the file indicated by the `--config`
# option, so we need to mirror the same configuration here and in `check-darker.toml`.
profile = "black"
known_first_party = ["darkgraylib", "graylint"]
known_third_party = ["pytest"]

[tool.darker]
# Only minimal options for Darker by default, so it's easier to test while developing.
# To check Darker's own code base with the full set of reformatters and linters, use:
# $ darker --config=check-darker.toml
src = [
"action",
"release_tools",
"src",
"setup.py",
]
revision = "origin/master..."

[tool.pylint."messages control"]
# Check import order only with isort. Pylint doesn't support a custom list of first
# party packages. We want to consider "darkgraylib" and "graylint" as first party.
disable = ["wrong-import-order"]

[tool.ruff]
target-version = "py38"

[tool.ruff.lint]
select = ["ALL"]
ignore = [
"ANN101", # Missing type annotation for `self` in method
"D203", # One blank line required before class docstring
"D213", # Multi-line docstring summary should start at the second line
"D400", # First line should end with a period (duplicates D415)
]

[tool.ruff.lint.per-file-ignores]
"src/darker/tests/*.py" = [
"ANN001", # Missing type annotation for function argument
"ANN201", # Missing return type annotation for public function
"ANN204", # Missing return type annotation for special method `__init__`
"C408", # Unnecessary `dict` call (rewrite as a literal)
"S101", # Use of `assert` detected
]
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,16 @@ test =
mypy>=0.990
pathspec # to test `gen_python_files` in `test_black_diff.py`
pip-requirements-parser
pydocstyle
pygments
pylint
pytest>=6.2.0
pytest-darker
pytest-kwparametrize>=0.0.3
regex>=2021.4.4
requests_cache>=0.7
ruamel.yaml>=0.17.21
ruff>=0.0.292
twine>=2.0.0
types-requests>=2.27.9
types-toml>=0.10.4
Expand Down

0 comments on commit acb6225

Please sign in to comment.