diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 53c39223..5594fa9a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,7 +8,7 @@ repos: - id: trailing-whitespace - id: end-of-file-fixer - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.9 + rev: v0.2.0 hooks: - id: ruff - id: ruff-format diff --git a/pyproject.toml b/pyproject.toml index ea4087b2..89c1b634 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,7 +38,7 @@ dynamic = ["version"] pg = ["psycopg[binary]"] etl = ["gffutils", "biocommons.seqrepo", "wags-tails>=0.1.1"] test = ["pytest>=6.0", "pytest-cov", "mock", "httpx"] -dev = ["pre-commit", "ruff>=0.1.9"] +dev = ["pre-commit", "ruff==0.2.0"] docs = [ "sphinx==6.1.3", "sphinx-autodoc-typehints==1.22.0", @@ -90,41 +90,87 @@ extend-exclude = "^/docs/source/conf.py" [tool.ruff] src = ["src"] exclude = ["docs/source/conf.py"] -# pycodestyle (E, W) -# Pyflakes (F) -# flake8-annotations (ANN) -# flake8-quotes (Q) -# pydocstyle (D) -# pep8-naming (N) -# isort (I) -select = ["E", "W", "F", "ANN", "Q", "D", "N", "I"] - -fixable = ["I", "F401"] +[tool.ruff.lint] +select = [ + "F", # https://docs.astral.sh/ruff/rules/#pyflakes-f + "E", "W", # https://docs.astral.sh/ruff/rules/#pycodestyle-e-w + "I", # https://docs.astral.sh/ruff/rules/#isort-i + "N", # https://docs.astral.sh/ruff/rules/#pep8-naming-n + "D", # https://docs.astral.sh/ruff/rules/#pydocstyle-d + "UP", # https://docs.astral.sh/ruff/rules/#pyupgrade-up + "ANN", # https://docs.astral.sh/ruff/rules/#flake8-annotations-ann + "ASYNC", # https://docs.astral.sh/ruff/rules/#flake8-async-async + "S", # https://docs.astral.sh/ruff/rules/#flake8-bandit-s + "B", # https://docs.astral.sh/ruff/rules/#flake8-bugbear-b + "A", # https://docs.astral.sh/ruff/rules/#flake8-builtins-a + "C4", # https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4 + "DTZ", # https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz + "T10", # https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz + "EM", # https://docs.astral.sh/ruff/rules/#flake8-errmsg-em + "G", # https://docs.astral.sh/ruff/rules/#flake8-logging-format-g + "PIE", # https://docs.astral.sh/ruff/rules/#flake8-pie-pie + "T20", # https://docs.astral.sh/ruff/rules/#flake8-print-t20 + "PT", # https://docs.astral.sh/ruff/rules/#flake8-pytest-style-pt + "Q", # https://docs.astral.sh/ruff/rules/#flake8-quotes-q + "RSE", # https://docs.astral.sh/ruff/rules/#flake8-raise-rse + "RET", # https://docs.astral.sh/ruff/rules/#flake8-return-ret + "SIM", # https://docs.astral.sh/ruff/rules/#flake8-simplify-sim + "PTH", # https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth + "PGH", # https://docs.astral.sh/ruff/rules/#pygrep-hooks-pgh + "RUF", # https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf +] +fixable = [ + "I", + "F401", + "D", + "UP", + "ANN", + "B", + "C4", + "G", + "PIE", + "PT", + "RSE", + "SIM", + "RUF" +] +# ANN101 - missing-type-self +# ANN003 - missing-type-kwargs # D203 - one-blank-line-before-class # D205 - blank-line-after-summary +# D206 - indent-with-spaces* # D213 - multi-line-summary-second-line +# D300 - triple-single-quotes* # D400 - ends-in-period # D415 - ends-in-punctuation -# ANN101 - missing-type-self -# ANN003 - missing-type-kwargs -# E501 - line-too-long -ignore = ["D203", "D205", "D213", "D400", "D415", "ANN101", "ANN003", "E501"] - -[tool.ruff.flake8-quotes] -docstring-quotes = "double" +# E111 - indentation-with-invalid-multiple* +# E114 - indentation-with-invalid-multiple-comment* +# E117 - over-indented* +# E501 - line-too-long* +# W191 - tab-indentation* +# S321 - suspicious-ftp-lib-usage +# *ignored for compatibility with formatter +ignore = [ + "ANN101", "ANN003", + "D203", "D205", "D206", "D213", "D300", "D400", "D415", + "E111", "E114", "E117", "E501", + "W191", + "S321", +] -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] # ANN001 - missing-type-function-argument # ANN2 - missing-return-type -# ANN201 - Missing type annotation # ANN102 - missing-type-cls -# D103 - Missing docstring in public function -# F821 - undefined-name # F401 - unused-import -# I001 - Import block unsorted or unformatted # N805 - invalid-first-argument-name-for-method -"tests/*" = ["ANN001", "ANN102", "ANN2"] +# S101 - assert +# B011 - assert-false +# D100 - undocumented-public-module +# D103 - undocumented-public-function +# I001 - unsorted-imports +"tests/*" = ["ANN001", "ANN2", "ANN102", "S101", "B011"] "*__init__.py" = ["F401"] "gene/schemas.py" = ["ANN001", "ANN201", "N805"] "docs/source/conf.py" = ["D100", "I001", "D103", "ANN201", "ANN001"]