Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TOML formatting using taplo #225

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ repos:
files: ^scripts/
- id: ruff-format
files: ^scripts/
- repo: https://github.com/ComPWA/mirrors-taplo
rev: v0.9.3
hooks:
- id: taplo-format
files: ^scripts/
1 change: 1 addition & 0 deletions .taplo.toml
23 changes: 10 additions & 13 deletions scripts/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ description = "scripts for ecosystem package data"
readme = "../README.md"
requires-python = ">=3.11"
license = "GPL-3.0"
authors = [
{ name = "Philipp A.", email = "[email protected]" },
]
authors = [{ name = "Philipp A.", email = "[email protected]" }]
urls.Documentation = "https://github.com/scverse/cookiecutter-scverse#readme"
urls.Issues = "https://github.com/scverse/cookiecutter-scverse/issues"
urls.Source = "https://github.com/scverse/cookiecutter-scverse"
Expand All @@ -23,15 +21,11 @@ dependencies = [
"GitPython",
"PyGitHub >= 2",
"PyYAML",
"pre-commit", # is ran by cruft
"pre-commit", # is ran by cruft
]

[project.optional-dependencies]
test = [
"pytest",
"pytest-socket",
"pytest-responsemock",
]
test = ["pytest", "pytest-socket", "pytest-responsemock"]

[project.scripts]
send-cruft-prs = "scverse_template_scripts.cruft_prs:cli"
Expand All @@ -55,7 +49,7 @@ addopts = [
"--import-mode=importlib",
"--disable-socket",
"-presponsemock",
"-ptesting.scverse_template_scripts._pytest"
"-ptesting.scverse_template_scripts._pytest",
]
filterwarnings = [
"error",
Expand Down Expand Up @@ -105,10 +99,13 @@ ignore = [
"S311", # we don’t need cryptographically secure RNG
"ISC001", # conflicts with formatter
]
unfixable = ["RUF001"] # never “fix” “confusables”
unfixable = ["RUF001"] # never “fix” “confusables”

[tool.ruff.lint.isort]
known-first-party = ["scverse_template_scripts", "testing.scverse_template_scripts"]
known-first-party = [
"scverse_template_scripts",
"testing.scverse_template_scripts",
]
required-imports = ["from __future__ import annotations"]

[tool.ruff.lint.flake8-type-checking]
Expand All @@ -118,5 +115,5 @@ strict = true
[tool.ruff.lint.per-file-ignores]
"tests/*.py" = [
"ARG001", # pytest fixtures don’t need to be used
"PLR0913", # allow as many pytest fixtures being used as one likes
"PLR0913", # allow as many pytest fixtures being used as one likes
]
4 changes: 4 additions & 0 deletions {{cookiecutter.project_name}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ repos:
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
types_or: [python, pyi, jupyter]
- repo: https://github.com/ComPWA/mirrors-taplo
rev: v0.9.3
hooks:
- id: taplo-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
Expand Down
2 changes: 2 additions & 0 deletions {{cookiecutter.project_name}}/.taplo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[formatting]
indent_string = " "
51 changes: 20 additions & 31 deletions {{cookiecutter.project_name}}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@ version = "0.0.1"
description = "{{ cookiecutter.project_description }}"
readme = "README.md"
requires-python = ">=3.10"
license = {file = "LICENSE"}
authors = [
{name = "{{ cookiecutter.author_full_name }}"},
]
maintainers = [
{name = "{{ cookiecutter.author_full_name }}", email = "{{ cookiecutter.author_email }}"},
]
license = { file = "LICENSE" }
authors = [{ name = "{{ cookiecutter.author_full_name }}" }]
maintainers = [{ name = "{{ cookiecutter.author_full_name }}", email = "{{ cookiecutter.author_email }}" }]
urls.Documentation = "https://{{ cookiecutter.project_name }}.readthedocs.io/"
urls.Source = "{{ cookiecutter.project_repo }}"
urls.Home-page = "{{ cookiecutter.project_repo }}"
Expand All @@ -25,17 +21,15 @@ dependencies = [
]

[project.optional-dependencies]
dev = [
"pre-commit",
"twine>=4.0.2",
]
dev = ["pre-commit", "twine>=4.0.2"]
doc = [
"docutils>=0.8,!=0.18.*,!=0.19.*",
"sphinx>=4",
"sphinx-book-theme>=1.0.0",
"myst-nb>=1.1.0",
"sphinxcontrib-bibtex>=1.0.0",
"setuptools", # Until pybtex >0.23.0 releases: https://bitbucket.org/pybtex-devs/pybtex/issues/169/
# Until pybtex >0.23.0 releases: https://bitbucket.org/pybtex-devs/pybtex/issues/169/
"setuptools",
"sphinx-autodoc-typehints",
"sphinxext-opengraph",
# For notebooks
Expand All @@ -44,10 +38,7 @@ doc = [
"sphinx-copybutton",
"pandas",
]
test = [
"pytest",
"coverage",
]
test = ["pytest", "coverage"]

{% if cookiecutter.project_name.lower().replace('-', '_') != cookiecutter.package_name -%}
[tool.hatch.build.targets.wheel]
Expand All @@ -57,15 +48,13 @@ packages = ['src/{{ cookiecutter.package_name }}']

[tool.coverage.run]
source = ["{{ cookiecutter.package_name }}"]
omit = [
"**/test_*.py",
]
omit = ["**/test_*.py"]

[tool.pytest.ini_options]
testpaths = ["tests"]
xfail_strict = true
addopts = [
"--import-mode=importlib", # allow using test files with same name
"--import-mode=importlib", # allow using test files with same name
]

[tool.ruff]
Expand All @@ -78,17 +67,17 @@ docstring-code-format = true

[tool.ruff.lint]
select = [
"F", # Errors detected by Pyflakes
"E", # Error detected by Pycodestyle
"W", # Warning detected by Pycodestyle
"I", # isort
"D", # pydocstyle
"B", # flake8-bugbear
"TID", # flake8-tidy-imports
"C4", # flake8-comprehensions
"BLE", # flake8-blind-except
"UP", # pyupgrade
"RUF100", # Report unused noqa directives
"F", # Errors detected by Pyflakes
"E", # Error detected by Pycodestyle
"W", # Warning detected by Pycodestyle
"I", # isort
"D", # pydocstyle
"B", # flake8-bugbear
"TID", # flake8-tidy-imports
"C4", # flake8-comprehensions
"BLE", # flake8-blind-except
"UP", # pyupgrade
"RUF100", # Report unused noqa directives
]
ignore = [
# line too long -> we accept long comment lines; formatter gets rid of long code lines
Expand Down
Loading