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 pyproject-fmt #299

Merged
merged 15 commits into from
Sep 2, 2024
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{yml,yaml}]
[*.{yml,yaml,toml}]
indent_size = 2

[Makefile]
Expand Down
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ repos:
hooks:
- id: prettier
# Hooks that are run for scripts
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "2.2.1"
hooks:
- id: pyproject-fmt
files: ^scripts/
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.2
hooks:
Expand Down
174 changes: 86 additions & 88 deletions scripts/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"
requires = [ "hatch-vcs", "hatchling" ]

[project]
name = "scverse-template-scripts"
dynamic = ["version"]
description = "scripts for ecosystem package data"
readme = "../README.md"
requires-python = ">=3.11"
license = "GPL-3.0"
authors = [
{ name = "Philipp A.", email = "[email protected]" },
{ 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"
requires-python = ">=3.11"
classifiers = [
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dynamic = [ "version" ]
dependencies = [
"cruft",
"rich",
"typer",
"furl",
"GitPython",
"PyGitHub >= 2",
"PyYAML",
"pre-commit", # is ran by cruft
"cruft",
"furl",
"gitpython",
"pre-commit", # is ran by cruft
"pygithub>=2",
"pyyaml",
"rich",
"typer",
]

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

[project.scripts]
send-cruft-prs = "scverse_template_scripts.cruft_prs:cli"
make-rich-output = "scverse_template_scripts.make_rich_output:main"
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"
scripts.make-rich-output = "scverse_template_scripts.make_rich_output:main"
scripts.send-cruft-prs = "scverse_template_scripts.cruft_prs:cli"

[tool.hatch.build.targets.wheel]
packages = ["src/testing", "src/scverse_template_scripts"]
packages = [ "src/testing", "src/scverse_template_scripts" ]

[tool.hatch.version]
source = "vcs"
Expand All @@ -48,75 +49,72 @@ fallback-version = "0.0"
python = "3.11"

[tool.hatch.envs.hatch-test]
features = ["test"]

[tool.pytest.ini_options]
addopts = [
"--import-mode=importlib",
"--disable-socket",
"-presponsemock",
"-ptesting.scverse_template_scripts._pytest"
]
filterwarnings = [
"error",
# https://github.com/man-group/pytest-plugins/issues/224
"ignore::DeprecationWarning:pytest_shutil",
]
features = [ "test" ]

[tool.ruff]
line-length = 120

[tool.ruff.format]
docstring-code-format = true
format.docstring-code-format = true

[tool.ruff.lint]
allowed-confusables = ["’", "×"]
select = [
"A",
"ARG",
"B",
"C",
"DTZ",
"E",
"EM",
"F",
"FBT",
"I",
"ICN",
"ISC",
"N",
"PLC",
"PLE",
"PLR",
"PLW",
"Q",
"RUF",
"S",
"T",
"TCH",
"TID",
"UP",
"W",
"YTT",
lint.select = [
"A",
"ARG",
"B",
"C",
"DTZ",
"E",
"EM",
"F",
"FBT",
"I",
"ICN",
"ISC",
"N",
"PLC",
"PLE",
"PLR",
"PLW",
"Q",
"RUF",
"S",
"T",
"TCH",
"TID",
"UP",
"W",
"YTT",
]
ignore = [
"S101", # assert should be allowed
"S603", # subprocess with shell=False should be allowed
"S311", # we don’t need cryptographically secure RNG
"ISC001", # conflicts with formatter
lint.ignore = [
"ISC001", # conflicts with formatter
"S101", # assert should be allowed
"S311", # we don’t need cryptographically secure RNG
"S603", # subprocess with shell=False should be allowed
]
unfixable = ["RUF001"] # never “fix” “confusables”

[tool.ruff.lint.isort]
known-first-party = ["scverse_template_scripts", "testing.scverse_template_scripts"]
required-imports = ["from __future__ import annotations"]
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
]
lint.unfixable = [
"RUF001", # never “fix” “confusables”
]
lint.allowed-confusables = [ "×", "’" ]
lint.flake8-type-checking.exempt-modules = [ ]
lint.flake8-type-checking.strict = true
lint.isort.known-first-party = [ "scverse_template_scripts", "testing.scverse_template_scripts" ]
lint.isort.required-imports = [ "from __future__ import annotations" ]

[tool.ruff.lint.flake8-type-checking]
exempt-modules = []
strict = true
[tool.pyproject-fmt]
column_width = 120

[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
[tool.pytest.ini_options]
addopts = [
"--import-mode=importlib",
"--disable-socket",
"-presponsemock",
"-ptesting.scverse_template_scripts._pytest",
]
filterwarnings = [
"error",
# https://github.com/man-group/pytest-plugins/issues/224
"ignore::DeprecationWarning:pytest_shutil",
]
5 changes: 1 addition & 4 deletions {{cookiecutter.project_name}}/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{yml,yaml}]
indent_size = 2

[.cruft.json]
[{*.{yml,yaml,toml},.cruft.json}]
indent_size = 2

[Makefile]
Expand Down
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 @@ -10,6 +10,10 @@ repos:
rev: v4.0.0-alpha.8
hooks:
- id: prettier
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "2.2.1"
hooks:
- id: pyproject-fmt
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.2
hooks:
Expand Down
Loading
Loading