Skip to content

Commit

Permalink
symlink some folders and use ruff for formatting instead of black (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Chan authored Feb 9, 2024
2 parents 6d08806 + bc59492 commit f6a7685
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 165 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
# Common links that should be available on every page
rst_epilog = """
.. _Diamond Light Source: http://www.diamond.ac.uk
.. _black: https://github.com/psf/black
.. _ruff: https://github.com/astral-sh/ruff
.. _flake8: https://flake8.pycqa.org/en/latest/
.. _isort: https://github.com/PyCQA/isort
.. _pyright: https://microsoft.github.io/pyright/#/
Expand Down
16 changes: 8 additions & 8 deletions docs/explanations/decisions/0008-use-tox.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ There are a number of things that CI needs to run:

- pytest
- black
- pyright
- mypy
- flake8
- isort
- build documentation
Expand All @@ -45,7 +45,7 @@ under pytest that had a plugin, and isort under flake8:
subgraph cluster_0 {
label = "pytest"
"pytest-black"
"pytest-pyright"
"pytest-mypy"
subgraph cluster_1 {
label = "pytest-flake8"
"flake8-isort"
Expand All @@ -69,14 +69,14 @@ To address this, the tree was rearranged:
pytest
black
pyright
mypy
subgraph cluster_1 {
label = "flake8"
"flake8-isort"
}
```

If using VSCode, this will still run black, flake8 and pyright on file save, but
If using VSCode, this will still run black, flake8 and mypy on file save, but
for those using other editors and for CI another solution was needed. Enter
[pre-commit](https://pre-commit.com/). This allows hooks to be run at `git
commit` time on just the files that have changed, as well as on all tracked
Expand All @@ -87,7 +87,7 @@ $ pre-commit install
```

Finally tox was added to run all of the CI checks including
the documentation build. pyright was moved out of the pre-commit and into tox
the documentation build. mypy was moved out of the pre-commit and into tox
because it was quite long running and
therefore intrusive. tox can be invoked to run all the checks in
parallel with:
Expand All @@ -109,7 +109,7 @@ The graph now looks like:
{
label = "tox -p"
pytest
pyright
mypy
"sphinx-build"
subgraph cluster_1 {
label = "pre-commit"
Expand All @@ -124,11 +124,11 @@ The graph now looks like:

Now the workflow looks like this:

- Save file, VSCode runs black, flake8 and pyright on it
- Save file, VSCode runs black, flake8 and mypy on it
- Run 'tox -p' and fix issues until it succeeds
- Commit files and pre-commit runs black and flake8 on them (if the
developer had not run tox then this catches some of the most common issues)
- Push to remote and CI runs black, flake8, pyright once on all files
- Push to remote and CI runs black, flake8, mypy once on all files
(using tox), then pytest multiple times in a test matrix

## Consequences
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/standards.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Code Standards

The code in this repository conforms to standards set by the following tools:

- black_ for code formatting
- ruff_ for code formatting
- flake8_ for style checks
- isort_ for import ordering
- pyright_ for static type checking
Expand Down
1 change: 1 addition & 0 deletions template/.devcontainer
50 changes: 0 additions & 50 deletions template/.devcontainer/devcontainer.json

This file was deleted.

23 changes: 0 additions & 23 deletions template/.pre-commit-config.yaml

This file was deleted.

1 change: 1 addition & 0 deletions template/.pre-commit-config.yaml
1 change: 1 addition & 0 deletions template/.vscode
10 changes: 0 additions & 10 deletions template/.vscode/extensions.json

This file was deleted.

25 changes: 0 additions & 25 deletions template/.vscode/launch.json

This file was deleted.

21 changes: 0 additions & 21 deletions template/.vscode/settings.json.jinja

This file was deleted.

16 changes: 0 additions & 16 deletions template/.vscode/tasks.json

This file was deleted.

1 change: 0 additions & 1 deletion template/pyproject.toml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ requires-python = ">=3.7"

[project.optional-dependencies]
dev = [
"black",
"copier",
"myst-parser",
"pipdeptree",
Expand Down
9 changes: 0 additions & 9 deletions template/{% if sphinx %}docs{% endif %}/conf.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,6 @@ intersphinx_mapping = {"python": ("https://docs.python.org/3/", None)}
# A dictionary of graphviz graph attributes for inheritance diagrams.
inheritance_graph_attrs = {"rankdir": "TB"}

# Common links that should be available on every page
rst_epilog = """
.. _Diamond Light Source: http://www.diamond.ac.uk
.. _black: https://github.com/psf/black
.. _ruff: https://beta.ruff.rs/docs/
.. _pyright: https://microsoft.github.io/pyright/#/
.. _pre-commit: https://pre-commit.com/
"""

# Ignore localhost links for periodic check that links in docs are valid
linkcheck_ignore = [r"http://localhost:\d+/"]

Expand Down

0 comments on commit f6a7685

Please sign in to comment.