diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 65d7d588..d4145eb7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,6 +6,11 @@ repos: - id: biome-format additional_dependencies: ["@biomejs/biome@1.8.3"] # Hooks that are run for scripts + - repo: https://github.com/tox-dev/pyproject-fmt + rev: "2.1.4" + hooks: + - id: pyproject-fmt + files: ^scripts/ - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.5.5 hooks: diff --git a/scripts/pyproject.toml b/scripts/pyproject.toml index 9ca00a9a..4af905be 100644 --- a/scripts/pyproject.toml +++ b/scripts/pyproject.toml @@ -1,44 +1,50 @@ [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 = "flying-sheep@web.de" }, + { name = "Philipp A.", email = "flying-sheep@web.de" }, +] +requires-python = ">=3.11" +classifiers = [ + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", +] +dynamic = [ + "version", ] -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" 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" @@ -48,75 +54,75 @@ 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 +] +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", ] -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"] - -[tool.ruff.lint.flake8-type-checking] -exempt-modules = [] -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 +[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", ] diff --git a/{{cookiecutter.project_name}}/pyproject.toml b/{{cookiecutter.project_name}}/pyproject.toml index 7a7a36e3..2538962a 100644 --- a/{{cookiecutter.project_name}}/pyproject.toml +++ b/{{cookiecutter.project_name}}/pyproject.toml @@ -10,39 +10,39 @@ readme = "README.md" requires-python = ">=3.10" license = {file = "LICENSE"} authors = [ - {name = "{{ cookiecutter.author_full_name }}"}, + {name = "{{ cookiecutter.author_full_name }}"}, ] maintainers = [ - {name = "{{ cookiecutter.author_full_name }}", email = "{{ cookiecutter.author_email }}"}, + {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 }}" dependencies = [ - "anndata", - # for debug logging (referenced from the issue template) - "session-info", + "anndata", + # for debug logging (referenced from the issue template) + "session-info", ] [project.optional-dependencies] dev = [ - "pre-commit", - "twine>=4.0.2", + "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/ - "sphinx-autodoc-typehints", - "sphinxext-opengraph", - # For notebooks - "ipykernel", - "ipython", - "sphinx-copybutton", - "pandas", + "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/ + "sphinx-autodoc-typehints", + "sphinxext-opengraph", + # For notebooks + "ipykernel", + "ipython", + "sphinx-copybutton", + "pandas", ] test = [ "pytest", @@ -78,44 +78,44 @@ 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 - "E501", - # Do not assign a lambda expression, use a def -> lambda expression assignments are convenient - "E731", - # allow I, O, l as variable names -> I is the identity matrix - "E741", - # Missing docstring in public package - "D104", - # Missing docstring in public module - "D100", - # Missing docstring in __init__ - "D107", - # Errors from function calls in argument defaults. These are fine when the result is immutable. - "B008", - # __magic__ methods are often self-explanatory, allow missing docstrings - "D105", - # first line should end with a period [Bug: doesn't work with single-line docstrings] - "D400", - # First line should be in imperative mood; try rephrasing - "D401", - ## Disable one in each pair of mutually incompatible rules - # We don’t want a blank line before a class docstring - "D203", - # We want docstrings to start immediately after the opening triple quote - "D213", + # line too long -> we accept long comment lines; formatter gets rid of long code lines + "E501", + # Do not assign a lambda expression, use a def -> lambda expression assignments are convenient + "E731", + # allow I, O, l as variable names -> I is the identity matrix + "E741", + # Missing docstring in public package + "D104", + # Missing docstring in public module + "D100", + # Missing docstring in __init__ + "D107", + # Errors from function calls in argument defaults. These are fine when the result is immutable. + "B008", + # __magic__ methods are often self-explanatory, allow missing docstrings + "D105", + # first line should end with a period [Bug: doesn't work with single-line docstrings] + "D400", + # First line should be in imperative mood; try rephrasing + "D401", + ## Disable one in each pair of mutually incompatible rules + # We don’t want a blank line before a class docstring + "D203", + # We want docstrings to start immediately after the opening triple quote + "D213", ] [tool.ruff.lint.pydocstyle] @@ -128,12 +128,12 @@ convention = "numpy" [tool.cruft] skip = [ - "tests", - "src/**/__init__.py", - "src/**/basic.py", - "docs/api.md", - "docs/changelog.md", - "docs/references.bib", - "docs/references.md", - "docs/notebooks/example.ipynb", + "tests", + "src/**/__init__.py", + "src/**/basic.py", + "docs/api.md", + "docs/changelog.md", + "docs/references.bib", + "docs/references.md", + "docs/notebooks/example.ipynb", ]