Skip to content
Open
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
26 changes: 26 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
default_install_hook_types: [pre-commit]

repos:

# Ruff linting / formatting
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.17
hooks:
- id: ruff-check
files: (src|tests)/.*\.py
- id: ruff-format
files: (src|tests)/.*\.py

# Mypy type checking
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v2.1.0
hooks:
- id: mypy

# Docs formatting with blackdoc
- repo: https://github.com/keewis/blackdoc
rev: v0.4.2
hooks:
- id: blackdoc
files: docs/
additional_dependencies: ["black==25.9.0"]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ pull request.
Additional dependencies for development can be installed as follows:
```sh
pip install --editable .[dev]
pre-commit install
```

Full details for contribution and developers can be found in the
Expand Down
11 changes: 7 additions & 4 deletions docs/developer/guidelines.rst
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,14 @@ Thus, good style is a requirement for submitting code to *TCTrack*.
- `mypy <http://mypy-lang.org/>`_ for static type checking of
`type hints <https://docs.python.org/3/library/typing.html>`_.

These will be checked on all pull requests and commits to main, so it is suggested you
run them on your code before committing.
These will be checked on all pull requests and commits to main, but it is suggested that you install the ``pre-commit`` hooks so that any changes will be checked each time you commit:

This can be done with a development install by running the following bash commands from
the root directory:
.. code-block:: shell

pre-commit install

To manually run the checks instead, run the following bash commands from the root
directory with a development installation:

.. code-block:: shell

Expand Down
3 changes: 2 additions & 1 deletion docs/getting-started/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ pip can then be run to install the code from the source into the environment::
pip install .

If you are developing TCTrack you should install as an editable package with the
additional developer dependencies::
additional developer dependencies and the pre-commit hooks installed::

pip install --editable .[dev]
pre-commit install

The `dev` optional dependencies include the `test`, `lint`, and `doc` subgroups.

Expand Down
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ test = [
"xarray",
]
lint = [
"pre-commit",
"ruff",
"blackdoc<=0.4.2",
"black<=25.1.0", # Pin version due to blackdoc incompatibility. Remove once resolved
"blackdoc>=0.4.2", # Pin versions for black-blackdoc compatibilty.
"black>=25.9.0", # See https://blackdoc.readthedocs.io/en/latest/changelog.html
"mypy",
"pytest",
"xarray",
Expand All @@ -58,8 +59,6 @@ doc = [
"sphinx<8.2.0", # Pin version due to autodoc type hints incompatibilities
"sphinx_rtd_theme",
"sphinx_autodoc_typehints",
"blackdoc<=0.4.2",
"black<=25.1.0", # Pin version due to blackdoc incompatibility. Remove once resolved
]
dev = [
"tctrack[test,lint,doc]",
Expand Down
Loading