From c353b44e7b49024f9d3fe7932fc35202b48dcbcc Mon Sep 17 00:00:00 2001 From: "Philipp A." Date: Fri, 22 Nov 2024 14:36:04 +0100 Subject: [PATCH] Update formatting (#63) --- .pre-commit-config.yaml | 23 +++---- .prettierrc.cjs | 20 ------ .vscode/extensions.json | 6 +- .vscode/settings.json | 4 +- biome.jsonc | 19 +++++ pyproject.toml | 92 +++++++++++++------------ src/legacy_api_wrap/__init__.py | 1 + src/testing/legacy_api_wrap/__init__.py | 1 + src/testing/legacy_api_wrap/pytest.py | 1 + tests/test_basic.py | 1 + 10 files changed, 89 insertions(+), 79 deletions(-) delete mode 100644 .prettierrc.cjs create mode 100644 biome.jsonc diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5e4608f..d1c9416 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,3 @@ -minimum_pre_commit_version: "2.21.0" # rust version selection -ci: - skip: [taplo] repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v5.0.0 @@ -12,18 +9,18 @@ repos: hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] - - repo: https://github.com/pre-commit/mirrors-prettier - rev: v4.0.0-alpha.8 + - id: ruff + args: [--preview, --select=CPY] + - id: ruff-format + - repo: https://github.com/biomejs/pre-commit + rev: v0.5.0 hooks: - - id: prettier - additional_dependencies: - - prettier - - prettier-plugin-jinja-template - - repo: https://github.com/ComPWA/mirrors-taplo - rev: v0.8.1 + - id: biome-format + additional_dependencies: ["@biomejs/biome@1.9.4"] + - repo: https://github.com/tox-dev/pyproject-fmt + rev: v2.5.0 hooks: - - id: taplo - language_version: stable + - id: pyproject-fmt - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.13.0 hooks: diff --git a/.prettierrc.cjs b/.prettierrc.cjs deleted file mode 100644 index ad331ad..0000000 --- a/.prettierrc.cjs +++ /dev/null @@ -1,20 +0,0 @@ -module.exports = { - plugins: [require.resolve("prettier-plugin-jinja-template")], - overrides: [ - { - files: [".vscode/*.json"], - options: { - parser: "json5", - quoteProps: "preserve", - singleQuote: false, - trailingComma: "all", - }, - }, - { - files: ["*.html"], - options: { - parser: "jinja-template", - }, - }, - ], -}; diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 9a3dfb6..769fba2 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,3 +1,7 @@ { - "recommendations": ["charliermarsh.ruff", "ms-python.python"], + "recommendations": [ + "charliermarsh.ruff", + "ms-python.python", + "biomejs.biome", + ], } diff --git a/.vscode/settings.json b/.vscode/settings.json index 15ce61e..17c6ff4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -10,8 +10,8 @@ "source.organizeImports": "always", }, }, - "[toml]": { + "[json][jsonc]": { "editor.formatOnSave": true, - "editor.defaultFormatter": "tamasfe.even-better-toml", + "editor.defaultFormatter": "biomejs.biome", }, } diff --git a/biome.jsonc b/biome.jsonc new file mode 100644 index 0000000..b0353a5 --- /dev/null +++ b/biome.jsonc @@ -0,0 +1,19 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.8.3/schema.json", + "overrides": [ + { + "include": ["./.vscode/*.json", "**/*.jsonc"], + "json": { + "formatter": { + "trailingCommas": "all", + "indentStyle": "space", + "indentWidth": 4, + }, + "parser": { + "allowComments": true, + "allowTrailingCommas": true, + }, + }, + }, + ], +} diff --git a/pyproject.toml b/pyproject.toml index b2de9ec..9d27f15 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,52 +1,70 @@ +[build-system] +build-backend = "hatchling.build" +requires = [ "hatch-docstring-description", "hatch-vcs", "hatchling" ] + [project] -dynamic = ["version", "description"] name = "legacy-api-wrap" -authors = [{ name = "Philipp A.", email = "flying-sheep@web.de" }] -urls.Source = "https://github.com/flying-sheep/legacy-api-wrap" readme = "README.rst" license = "MPL-2.0" +authors = [ { name = "Philipp A.", email = "flying-sheep@web.de" } ] requires-python = ">=3.8" classifiers = [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", - "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Topic :: Software Development :: Libraries :: Python Modules", "Typing :: Typed", ] -dependencies = [] -[project.optional-dependencies] -test = [ - "pytest", +dynamic = [ "description", "version" ] +dependencies = [ ] +optional-dependencies.test = [ + "anyconfig[toml]>=0.14", # coverage-rich uses anyconfig "coverage", "coverage-rich", - "anyconfig[toml] >=0.14", # coverage-rich uses anyconfig + "pytest", ] +urls.Source = "https://github.com/flying-sheep/legacy-api-wrap" + +[tool.hatch.version] +source = "vcs" +[tool.hatch.build.targets.wheel] +packages = [ "src/legacy_api_wrap", "src/testing/legacy_api_wrap" ] + +[tool.hatch.envs.test] +features = [ "test" ] +[tool.hatch.envs.test.scripts] +run = "pytest {args}" +cov = "coverage run -m pytest {args} && coverage-rich report && coverage html" +[[tool.hatch.envs.test.matrix]] +python = [ "3.8", "3.9", "3.10", "3.11" ] [tool.ruff] line-length = 100 -select = ["ALL"] -ignore = [ - "D203", # zero instead of one blank lines before class - "D213", # multiline summary on first instead of second line +lint.select = [ "ALL" ] +lint.ignore = [ + "COM812", # incompatible with formatter + "D203", # zero instead of one blank lines before class + "D213", # multiline summary on first instead of second line + "ISC001", # incompatible with formatter ] -allowed-confusables = ["’"] -[tool.ruff.isort] -known-first-party = ["legacy_api_wrap"] -required-imports = ["from __future__ import annotations"] -[tool.ruff.extend-per-file-ignores] -"src/testing/*.py" = ["INP001"] -"tests/**/test_*.py" = [ +lint.extend-per-file-ignores."src/testing/*.py" = [ "INP001" ] +lint.extend-per-file-ignores."tests/**/test_*.py" = [ "D100", # tests need no module docstrings "D103", # tests need no function docstrings "INP001", # tests should not have __init__.py "PLR2004", # tests use magic values "S101", # tests use `assert` ] - -[tool.mypy] -strict = true -explicit_package_bases = true -mypy_path = "src" +lint.allowed-confusables = [ "’" ] +lint.flake8-copyright.notice-rgx = "SPDX-License-Identifier: MPL-2\\.0" +lint.isort.known-first-party = [ "legacy_api_wrap" ] +lint.isort.required-imports = [ "from __future__ import annotations" ] [tool.pytest.ini_options] addopts = [ @@ -62,22 +80,10 @@ addopts = [ run.data_file = "test-data/coverage" xml.output = "test-data/coverage.xml" html.directory = "test-data/htmlcov" -run.omit = ["src/testing/*", "tests/*"] -report.exclude_also = ["if TYPE_CHECKING:"] - -[tool.hatch.version] -source = "vcs" -[tool.hatch.build.targets.wheel] -packages = ["src/legacy_api_wrap", "src/testing/legacy_api_wrap"] +run.omit = [ "src/testing/*", "tests/*" ] +report.exclude_also = [ "if TYPE_CHECKING:" ] -[tool.hatch.envs.test] -features = ["test"] -[tool.hatch.envs.test.scripts] -run = "pytest {args}" -cov = "coverage run -m pytest {args} && coverage-rich report && coverage html" -[[tool.hatch.envs.test.matrix]] -python = ["3.8", "3.9", "3.10", "3.11"] - -[build-system] -requires = ["hatchling", "hatch-vcs", "hatch-docstring-description"] -build-backend = "hatchling.build" +[tool.mypy] +strict = true +explicit_package_bases = true +mypy_path = "src" diff --git a/src/legacy_api_wrap/__init__.py b/src/legacy_api_wrap/__init__.py index 7d5dc4f..0969079 100644 --- a/src/legacy_api_wrap/__init__.py +++ b/src/legacy_api_wrap/__init__.py @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: MPL-2.0 """Legacy API wrapper. >>> from legacy_api_wrap import legacy_api diff --git a/src/testing/legacy_api_wrap/__init__.py b/src/testing/legacy_api_wrap/__init__.py index 6a8525c..6738bbb 100644 --- a/src/testing/legacy_api_wrap/__init__.py +++ b/src/testing/legacy_api_wrap/__init__.py @@ -1 +1,2 @@ +# SPDX-License-Identifier: MPL-2.0 """Testing utils for legacy_api_wrap.""" diff --git a/src/testing/legacy_api_wrap/pytest.py b/src/testing/legacy_api_wrap/pytest.py index da5e69f..fb31fb7 100644 --- a/src/testing/legacy_api_wrap/pytest.py +++ b/src/testing/legacy_api_wrap/pytest.py @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: MPL-2.0 """Pytest plugin for legacy_api_wrap.""" from __future__ import annotations diff --git a/tests/test_basic.py b/tests/test_basic.py index ffac046..a7d6fe4 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: MPL-2.0 from __future__ import annotations from inspect import signature