diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 3d94dbae..00000000 --- a/.flake8 +++ /dev/null @@ -1,18 +0,0 @@ -[flake8] -max-line-length=100 -select= - # flake8-mccabe - C901, - # flake8-pycodestyle - E, - # flake8-pyflakes - F, - # flake8-pycodestyle - W, -ignore = - # conflict with black formatter - W503,E203, -per-file-ignores = - # supression for __init__ - diff_cover/tests/*: E501 - diff_cover/tests/fixtures/*: E,F,W \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 32d7c945..0d4c1efe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,22 +70,6 @@ toml = ["tomli"] requires = ["poetry-core>=1.0.7"] build-backend = "poetry.core.masonry.api" -[tool.black] -line-length = 88 -target-version = ['py310'] -include = '\.pyi?$' -exclude = "tests/fixtures/*" - -[tool.isort] -profile = "black" -extend_skip = "tests/fixtures/" - -[tool.pylint.master] -max-line-length = 100 -load-plugins = [ - "pylint_pytest", -] - [tool.coverage.run] branch = true relative_files = true @@ -109,45 +93,6 @@ exclude_also = [ show_contexts = true skip_covered = false -[tool.pylint."messages control"] -enable = ["all"] -disable = [ - # allow TODO comments - "fixme", - # allow disables - "locally-disabled", - "suppressed-message", - # covered by isort - "ungrouped-imports", - # allow classes and functions w/o docstring - "missing-docstring", - # hard number checks can be ignored, because they are covered in code reviews - "too-many-instance-attributes", - "too-many-arguments", - "too-many-locals", - "too-many-branches", - "too-few-public-methods", - "too-many-nested-blocks", - "too-many-public-methods", - # allow methods not to use self - "no-self-use", - # currently some code seems duplicated for pylint - "duplicate-code", - # we are a command line tool and don't want to show all internals - "raise-missing-from", -] - -[tool.pylint.basic] -good-names = [ - "_", - "i", - "setUp", - "tearDown", - "e", - "ex", -] -no-docstring-rgx = "^_" - [tool.pytest.ini_options] addopts = "--strict-markers" xfail_strict = true @@ -157,3 +102,88 @@ markers = [ [tool.doc8] max_line_length = 120 + +[tool.ruff] +line-length = 88 +target-version = "py39" +src = ["diff_cover", "tests"] +exclude = ["tests/fixtures/*"] + +[tool.ruff.format] +quote-style = "double" +indent-style = "space" +skip-magic-trailing-comma = false +line-ending = "auto" + +[tool.ruff.lint] +select = ["ALL"] +ignore = [ + # Disable all annotations + "ANN", + # allow TODO comments (equivalent to "fixme") + "FIX", + + "D200", # Disables One-line docstring should fit on one line + "D205", # Disables 1 blank line required between summary line and description + "D212", # Disables Multi-line docstring summary should start at the first line + "D400", # Disables First line should end with a period + "D415", # Disables First line should end with a period, question mark, or exclamation point + + # allow disables (equivalent to "locally-disabled", "suppressed-message") + "RUF100", + + # covered by isort (equivalent to "ungrouped-imports") + "I", + + # allow classes and functions w/o docstring (equivalent to "missing-docstring") + "D1", + + # hard number checks (equivalent to "too-many-*" rules) + "C901", # complexity + "PLR0912", # too many branches + "PLR0913", # too many arguments + "PLR0914", # too many locals + "PLR0915", # too many statements + "PLR0916", # too many nested blocks + "PLR0904", # too many public methods + + # duplicate code detection (equivalent to "duplicate-code") + "CPY", + + # we are a command line tool (equivalent to "raise-missing-from") + "B904", + + # Resolve incompatible docstring rules + "D203", # Keep D211 (no-blank-line-before-class) + "D213", # Keep D212 (multi-line-summary-first-line) + + # Avoid formatter conflicts + "COM812", +] + +# The equivalent of pylint's good-names +allowed-confusables = ["_"] + +[tool.ruff.lint.pep8-naming] +# Allow specific names that might otherwise violate naming conventions +ignore-names = ["i", "e", "ex", "setUp", "tearDown"] + +[tool.ruff.lint.per-file-ignores] +"tests/*" = [ + "S101", # Disables Assert statements + "PLR2004", # Disables Magic value + "PT011", # Disables Exception is too broad + "RUF012", # Disables Mutable class attributes should be annotated with typing.ClassVar +] + +[tool.ruff.lint.pydocstyle] +# Equivalent to pylint's no-docstring-rgx +ignore-decorators = ["^_"] + +[tool.ruff.lint.isort] +known-first-party = ["diff_cover", "tests"] +section-order = ["future", "standard-library", "third-party", "first-party", "local-folder"] +lines-between-types = 0 +lines-after-imports = 2 +combine-as-imports = true +split-on-trailing-comma = false diff --git a/verify.sh b/verify.sh index 99996d59..a3152f4f 100755 --- a/verify.sh +++ b/verify.sh @@ -1,15 +1,14 @@ #!/bin/bash set -euo pipefail IFS=$'\n\t' +COMPARE_BRANCH=${COMPARE_BRANCH:-origin/main} -black diff_cover tests --check -isort diff_cover tests --check +ruff format --check +ruff check --select I python -m pytest -n auto --cov-context test --cov --cov-report=xml tests git fetch origin main:refs/remotes/origin/main diff-cover --version diff-quality --version -diff-cover coverage.xml --include-untracked -diff-quality --violations flake8 --include-untracked -diff-quality --violations pylint --include-untracked +diff-cover coverage.xml --include-untracked --compare-branch=$COMPARE_BRANCH +diff-quality --violations ruff.check --include-untracked --compare-branch=$COMPARE_BRANCH doc8 README.rst --ignore D001 -