diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6e92267..2877784 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,16 +1,11 @@ repos: - repo: https://github.com/tox-dev/pyproject-fmt - rev: "1.2.0" + rev: "1.4.1" hooks: - id: pyproject-fmt -# Ruff must be run before Black, so Black can reformat fixes made by Ruff - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.292 + rev: v0.1.3 hooks: + - id: ruff-format - id: ruff args: [--fix, --exit-non-zero-on-fix] -- repo: https://github.com/psf/black-pre-commit-mirror - rev: "23.9.1" - hooks: - - id: black - args: [--preview] diff --git a/pyproject.toml b/pyproject.toml index ce2f4d3..7039fd5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -85,8 +85,7 @@ python = "3.12" [tool.hatch.envs.lint] dependencies = [ - "black", - "ruff", + "ruff>=0.1.3", "mypy", "pyproject-fmt", "types-xmltodict", @@ -94,16 +93,16 @@ dependencies = [ [tool.hatch.envs.lint.scripts] lint = [ - "ruff check --fix --show-fixes .", - "black --preview .", + "ruff format .", + "ruff check --output-format=grouped --fix --show-source --show-fixes .", "mypy --package jinjanator_plugin_format_xml", "mypy tests", "shellcheck workflow-support/*.sh", "pyproject-fmt pyproject.toml", ] lint-action = [ + "ruff format --check --diff .", "ruff check --output-format=github .", - "black --check --diff --preview .", "mypy --package jinjanator_plugin_format_xml", "mypy tests", "shellcheck workflow-support/*.sh", @@ -175,28 +174,26 @@ replacement = '[\1](https://github.com/kpfleming/jinjanator-plugin-format-xml/tr pattern = "#(\\d+)" replacement = "[#\\1](https://github.com/kpfleming/jinjanator-plugin-format-xml/issues/\\1)" -[tool.black] -line-length = 90 -target-version = ["py38"] - [tool.ruff] src = ["src", "tests"] -output-format = "grouped" -target-version = "py38" +ignore-init-module-imports = true +line-length = 100 + +[tool.ruff.lint] select = ["ALL"] ignore = [ "ANN", # Mypy is better at this. + "COM812", # conflicts with formatter "C901", # Leave complexity to me. - "COM", # Leave commas to Black. "D", # We have different ideas about docstrings. - "E501", # leave line-length enforcement to Black + "ISC001", # conflicts with formatter "PLR0912", # Leave complexity to me. "TRY301", # Raise in try blocks can totally make sense. ] unfixable = ["F401"] -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "tests/*" = [ "PLC1901", # empty strings are falsey, but are less specific in tests "PT005", # we use always underscores and explicit names diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 917900d..5bacb06 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -19,9 +19,7 @@ def test_format() -> None: def test_format_namespaces() -> None: fmt = plugin.XMLFormat("process-namespaces") - result = fmt.parse( - 'bleu' - ) + result = fmt.parse('bleu') assert "testdoc" in result assert "http://a.com/:cheese" in result["testdoc"] assert "bleu" == result["testdoc"]["http://a.com/:cheese"] @@ -29,9 +27,7 @@ def test_format_namespaces() -> None: def test_format_ignore_namespaces() -> None: fmt = plugin.XMLFormat(None) - result = fmt.parse( - 'bleu' - ) + result = fmt.parse('bleu') assert "testdoc" in result assert "a:cheese" in result["testdoc"] assert "bleu" == result["testdoc"]["a:cheese"]