diff --git a/.cruft.json b/.cruft.json index 4b913167..b178710f 100644 --- a/.cruft.json +++ b/.cruft.json @@ -1,7 +1,7 @@ { "template": "https://github.com/scverse/cookiecutter-scverse", - "commit": "77339226581ec535e1972984083ae70b702e7bec", - "checkout": null, + "commit": "6518dfa1abde7379ea7255daf0ce09c23f2b4c94", + "checkout": "v0.8.0", "context": { "cookiecutter": { "project_name": "mudata", @@ -13,6 +13,7 @@ "github_repo": "mudata", "license": "BSD 3-Clause License", "ide_integration": false, + "issue_categorization": "issue types", "_copy_without_render": [ ".github/workflows/build.yaml", ".github/workflows/test.yaml", @@ -36,8 +37,10 @@ "trim_blocks": true }, "_template": "https://github.com/scverse/cookiecutter-scverse", - "_commit": "77339226581ec535e1972984083ae70b702e7bec" - } + "_commit": "4d6aa34fd5be7523ca3bd49fbd81a882dde01d1f" + }, + "_commit": "6518dfa1abde7379ea7255daf0ce09c23f2b4c94", + "_template": "https://github.com/scverse/cookiecutter-scverse" }, "directory": null } diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b3a4e4bc..c072948c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -14,11 +14,12 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +permissions: + contents: read + jobs: package: runs-on: ubuntu-latest - permissions: - contents: read steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 30b097c0..aa634229 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -21,6 +21,7 @@ jobs: name: pypi url: https://pypi.org/p/mudata permissions: + contents: read id-token: write # IMPORTANT: this permission is mandatory for trusted publishing steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ff2b9aa9..3fc3e3d9 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -26,7 +26,7 @@ jobs: # Check [[tool.hatch.envs.hatch-test.matrix]] in pyproject.toml and https://hatch.pypa.io/latest/environment/ for # more details. get-environments: - runs-on: ubuntu-latest + runs-on: ubuntu-slim outputs: envs: ${{ steps.get-envs.outputs.envs }} steps: @@ -56,6 +56,7 @@ jobs: needs: get-environments permissions: id-token: write # for codecov OIDC + contents: read strategy: fail-fast: false @@ -79,6 +80,8 @@ jobs: python-version: ${{ matrix.env.python }} - name: create hatch environment run: uvx hatch env create ${{ matrix.env.name }} + - name: list all all installed package versions + run: uvx hatch run ${{ matrix.env.name }}:uv pip list - name: run tests using hatch env: MPLBACKEND: agg @@ -87,7 +90,7 @@ jobs: run: uvx hatch run ${{ matrix.env.name }}:run-cov -v --color=yes -n auto - name: generate coverage report run: | - # See https://coverage.readthedocs.io/en/latest/config.html#run-patch + # See https://coverage.readthedocs.io/page/config.html#run-patch test -f .coverage || uvx hatch run ${{ matrix.env.name }}:cov-combine uvx hatch run ${{ matrix.env.name }}:cov-report # report visibly uvx hatch run ${{ matrix.env.name }}:coverage xml # create report for upload diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5f265d91..e43dcdd9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: - id: biome-format exclude: ^\.cruft\.json$ # inconsistent indentation with cruft - file never to be modified manually. - repo: https://github.com/tox-dev/pyproject-fmt - rev: v2.25.2 + rev: v2.25.3 hooks: - id: pyproject-fmt - repo: https://github.com/astral-sh/ruff-pre-commit diff --git a/.readthedocs.yaml b/.readthedocs.yaml index bd0b1f5b..67eb948d 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -1,4 +1,4 @@ -# https://docs.readthedocs.io/en/stable/config-file/v2.html +# https://docs.readthedocs.io/page/config-file/v2.html version: 2 build: os: ubuntu-24.04 diff --git a/docs/_static/.gitkeep b/docs/_static/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/docs/_static/css/custom.css b/docs/_static/css/custom.css new file mode 100644 index 00000000..b8c8d47f --- /dev/null +++ b/docs/_static/css/custom.css @@ -0,0 +1,4 @@ +/* Reduce the font size in data frames - See https://github.com/scverse/cookiecutter-scverse/issues/193 */ +div.cell_output table.dataframe { + font-size: 0.8em; +} diff --git a/docs/conf.py b/docs/conf.py index 26d8c121..f450255d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -2,7 +2,7 @@ # This file only contains a selection of the most common options. For a full # list see the documentation: -# https://www.sphinx-doc.org/en/master/usage/configuration.html +# https://www.sphinx-doc.org/page/usage/configuration.html # -- Path setup -------------------------------------------------------------- import shutil diff --git a/docs/contributing.md b/docs/contributing.md index d6361cfc..7d0d49fa 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -9,7 +9,7 @@ the [scientific Python tutorials][], or the [scanpy developer guide][]. [pyopensci tutorials]: https://www.pyopensci.org/learn.html [scientific Python tutorials]: https://learn.scientific-python.org/development/tutorials/ -[scanpy developer guide]: https://scanpy.readthedocs.io/en/latest/dev/index.html +[scanpy developer guide]: https://scanpy.scverse.org/page/dev/ :::{tip} The *hatch* project manager @@ -46,11 +46,21 @@ hatch test # defined in the table [tool.hatch.envs.hatch-test] in pyproject.tom hatch run docs:build # defined in the table [tool.hatch.envs.docs] ``` -When using an IDE such as VS Code, -you’ll have to point the editor at the paths to the virtual environments manually. -The environment you typically want to use as your main development environment is the `hatch-test` -environment with the latest Python version. +### VS Code +If you are using VS code, install the [hatch-code][] extension. +Additionally, make sure that the `vscode-python-environments` extension is installed (should be by default) +and `"python.useEnvironmentsExtension": true` is activated in your `settings.json`. + +Next, open the "Python Environment Managers" sidebar. +You can do so by opening the command palette (Ctrl+Shift+P) and searching for `Python: Focus on Environment Managers View`. +It will show a collapsible list where you can expand "Hatch" +and activate an environment by clicking on the checkmark next to it. +As the main development environment, we recommend to use `hatch-test` with the latest supported Python version. + +### Other IDEs + +For other IDEs, you’ll have to point the editor at the paths to the virtual environments manually. To get a list of all environments for your projects, run ```bash @@ -63,7 +73,7 @@ This will list “Standalone” environments and a table of “Matrix” environ +------------+---------+--------------------------+----------+---------------------------------+-------------+ | Name | Type | Envs | Features | Dependencies | Scripts | +------------+---------+--------------------------+----------+---------------------------------+-------------+ -| hatch-test | virtual | hatch-test.py3.11-stable | dev | coverage-enable-subprocess==1.0 | cov-combine | +| hatch-test | virtual | hatch-test.py3.12-stable | dev | coverage-enable-subprocess==1.0 | cov-combine | | | | hatch-test.py3.14-stable | test | coverage[toml]~=7.4 | cov-report | | | | hatch-test.py3.14-pre | | pytest-mock~=3.12 | run | | | | | | pytest-randomly~=3.15 | run-cov | @@ -74,6 +84,7 @@ This will list “Standalone” environments and a table of “Matrix” environ ``` From the `Envs` column, select the environment name you want to use for development. +As the main development environment, we recommend to use `hatch-test` with the latest supported Python version. In this example, it would be `hatch-test.py3.14-stable`. Next, create the environment with @@ -88,10 +99,7 @@ Then, obtain the path to the environment using hatch env find hatch-test.py3.14-stable ``` -In case you are using VScode, now open the command palette (Ctrl+Shift+P) and search for `Python: Select Interpreter`. -Choose `Enter Interpreter Path` and paste the path to the virtual environment from above. - -In this future, this may become easier through a hatch vscode extension. +and manually point it to the python binary. :::: @@ -134,24 +142,26 @@ The `.venv` directory is typically automatically discovered by IDEs such as VS C ::::: [hatch environments]: https://hatch.pypa.io/latest/tutorials/environment/basic-usage/ +[hatch-code]: https://marketplace.visualstudio.com/items?itemName=PyPA.hatch [uv]: https://docs.astral.sh/uv/ ## Code-style -This package uses [pre-commit][] to enforce consistent code-styles. -On every commit, pre-commit checks will either automatically fix issues with the code, or raise an error message. +This package uses [pre-commit][]-style hooks to enforce consistent code-styles. +We recommend running them with [prek][], a fast, drop-in replacement for `pre-commit` that reads the same `.pre-commit-config.yaml`. +On every commit, the checks will either automatically fix issues with the code, or raise an error message. -To enable pre-commit locally, simply run +To enable the checks locally, install [prek][] (e.g. with `uv tool install prek`) and run ```bash -pre-commit install +prek install ``` in the root of the repository. -Pre-commit will automatically download all dependencies when it is run for the first time. +prek will automatically download all dependencies when it is run for the first time. Alternatively, you can rely on the [pre-commit.ci][] service enabled on GitHub. -If you didn’t run `pre-commit` before pushing changes to GitHub it will automatically commit fixes to your pull request, or show an error message. +If you didn’t run the checks before pushing changes to GitHub it will automatically commit fixes to your pull request, or show an error message. If pre-commit.ci added a commit on a branch you still have been working on locally, simply use @@ -160,12 +170,13 @@ git pull --rebase ``` to integrate the changes into yours. -While the [pre-commit.ci][] is useful, we strongly encourage installing and running pre-commit locally first to understand its usage. +While the [pre-commit.ci][] is useful, we strongly encourage installing and running the checks locally first to understand their usage. Finally, most editors have an _autoformat on save_ feature. Consider enabling this option for [ruff][ruff-editors] and [biome][biome-editors]. [pre-commit]: https://pre-commit.com/ +[prek]: https://prek.j178.dev/ [pre-commit.ci]: https://pre-commit.ci/ [ruff-editors]: https://docs.astral.sh/ruff/integrations/ [biome-editors]: https://biomejs.dev/guides/integrate-in-editor/ @@ -178,12 +189,8 @@ This package uses [pytest][] for automated testing. Please write {doc}`scanpy:dev/testing` for every function added to the package. Most IDEs integrate with pytest and provide a GUI to run tests. -Just point yours to one of the environments returned by - -```bash -hatch env create hatch-test # create test environments for all supported versions -hatch env find hatch-test # list all possible test environment paths -``` +If you set up your virtual environments as described in [installing dev dependencies](#installing-dev-dependencies), +test cases should be automatically discovered by your IDE. Alternatively, you can run all tests from the command line by executing @@ -273,11 +280,11 @@ This project uses [sphinx][] with the following features: See scanpy’s {doc}`scanpy:dev/documentation` for more information on how to write your own. -[sphinx]: https://www.sphinx-doc.org/en/master/ -[myst]: https://myst-parser.readthedocs.io/en/latest/intro.html -[myst-nb]: https://myst-nb.readthedocs.io/en/latest/ -[numpydoc-napoleon]: https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html -[numpydoc]: https://numpydoc.readthedocs.io/en/latest/format.html +[sphinx]: https://www.sphinx-doc.org/ +[myst]: https://myst-parser.readthedocs.io/page/intro.html +[myst-nb]: https://myst-nb.readthedocs.io/ +[numpydoc-napoleon]: https://www.sphinx-doc.org/page/usage/extensions/napoleon.html +[numpydoc]: https://numpydoc.readthedocs.io/page/format.html [sphinx-autodoc-typehints]: https://github.com/tox-dev/sphinx-autodoc-typehints ### Tutorials with myst-nb and jupyter notebooks diff --git a/pyproject.toml b/pyproject.toml index d4d3034a..330e0fa9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,7 +45,7 @@ urls.Source = "https://github.com/scverse/mudata" [dependency-groups] dev = [ "mudata[io]", - "pre-commit", + "prek", "twine>=4.0.2", ] test = [ @@ -86,8 +86,10 @@ envs.docs.scripts.clean = "git clean -fdX -- {args:docs}" envs.docs.scripts.open = "python -m webbrowser -t docs/_build/html/index.html" envs.docs.dependency-groups = [ "doc" ] envs.hatch-test.matrix = [ + # Test the lowest and highest supported Python versions with normal deps { deps = [ "stable" ], python = [ "3.12", "3.14" ] }, - { deps = [ "pre" ], python = [ "3.14" ] } + # Test the newest supported Python version also with pre-release deps + { deps = [ "pre" ], python = [ "3.14" ] }, ] # If the matrix variable `deps` is set to "pre", # set the environment variable `UV_PRERELEASE` to "allow". @@ -163,6 +165,7 @@ run.source = [ "mudata" ] [tool.cruft] skip = [ + ".git", "tests", "src/**/__init__.py", "src/**/basic.py",