Skip to content

Commit

Permalink
Update formatting (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-sheep authored Nov 22, 2024
1 parent 921f33d commit c353b44
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 79 deletions.
23 changes: 10 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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/[email protected]"]
- 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:
Expand Down
20 changes: 0 additions & 20 deletions .prettierrc.cjs

This file was deleted.

6 changes: 5 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"recommendations": ["charliermarsh.ruff", "ms-python.python"],
"recommendations": [
"charliermarsh.ruff",
"ms-python.python",
"biomejs.biome",
],
}
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"source.organizeImports": "always",
},
},
"[toml]": {
"[json][jsonc]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "tamasfe.even-better-toml",
"editor.defaultFormatter": "biomejs.biome",
},
}
19 changes: 19 additions & 0 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -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,
},
},
},
],
}
92 changes: 49 additions & 43 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]" }]
urls.Source = "https://github.com/flying-sheep/legacy-api-wrap"
readme = "README.rst"
license = "MPL-2.0"
authors = [ { name = "Philipp A.", email = "[email protected]" } ]
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 = [
Expand All @@ -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"
1 change: 1 addition & 0 deletions src/legacy_api_wrap/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# SPDX-License-Identifier: MPL-2.0
"""Legacy API wrapper.
>>> from legacy_api_wrap import legacy_api
Expand Down
1 change: 1 addition & 0 deletions src/testing/legacy_api_wrap/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# SPDX-License-Identifier: MPL-2.0
"""Testing utils for legacy_api_wrap."""
1 change: 1 addition & 0 deletions src/testing/legacy_api_wrap/pytest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# SPDX-License-Identifier: MPL-2.0
"""Pytest plugin for legacy_api_wrap."""

from __future__ import annotations
Expand Down
1 change: 1 addition & 0 deletions tests/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# SPDX-License-Identifier: MPL-2.0
from __future__ import annotations

from inspect import signature
Expand Down

0 comments on commit c353b44

Please sign in to comment.