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 750c6e1..70f7eaa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -83,8 +83,7 @@ python = "3.12" [tool.hatch.envs.lint] dependencies = [ - "black", - "ruff", + "ruff>=0.1.3", "mypy", "pyproject-fmt", "pytest", # needed for type-checking plugin_example @@ -92,8 +91,8 @@ 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_plugins", "mypy tests", "mypy plugin_example", @@ -101,8 +100,8 @@ lint = [ "pyproject-fmt pyproject.toml plugin_example/pyproject.toml", ] lint-action = [ + "ruff format --check --diff .", "ruff check --output-format=github .", - "black --check --diff --preview .", "mypy --package jinjanator_plugins", "mypy tests", "mypy plugin_example", @@ -173,28 +172,26 @@ replacement = '[\1](https://github.com/kpfleming/jinjanator-plugins/tree/main/\g pattern = "#(\\d+)" replacement = "[#\\1](https://github.com/kpfleming/jinjanator-plugins/issues/\\1)" -[tool.black] -line-length = 90 -target-version = ["py38"] - [tool.ruff] src = ["src"] -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/*" = [ "INP001", # we don't care that these are in implicit namespace packages "PLC1901", # empty strings are falsey, but are less specific in tests diff --git a/src/jinjanator_plugins/__init__.py b/src/jinjanator_plugins/__init__.py index 86d3887..c416074 100644 --- a/src/jinjanator_plugins/__init__.py +++ b/src/jinjanator_plugins/__init__.py @@ -24,9 +24,11 @@ class Format(Protocol): suffixes: Iterable[str] | None option_names: Iterable[str] | None - def __init__(self, options: Iterable[str] | None) -> None: ... # pragma: no cover + def __init__(self, options: Iterable[str] | None) -> None: + ... # pragma: no cover - def parse(self, data_string: str) -> Mapping[str, Any]: ... # pragma: no cover + def parse(self, data_string: str) -> Mapping[str, Any]: + ... # pragma: no cover class FormatOptionUnknownError(Exception):