Skip to content

Commit 6c546b5

Browse files
authored
Replace black with ruff format (#101)
* use ruff as formatter * remove black config
1 parent 73e88fc commit 6c546b5

File tree

6 files changed

+14
-32
lines changed

6 files changed

+14
-32
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ This is a modern Cookiecutter template that can be used to initiate a Python pro
1616
- CI/CD with [GitHub Actions](https://github.com/features/actions)
1717
- Pre-commit hooks with [pre-commit](https://pre-commit.com/)
1818
- Code quality with:
19-
- [black](https://pypi.org/project/black/)
2019
- [ruff](https://github.com/charliermarsh/ruff)
2120
- [mypy](https://mypy.readthedocs.io/en/stable/)
2221
- [deptry](https://github.com/fpgmaas/deptry/)

docs/features/linting.md

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,9 @@ Note that this requires the pre-commit hooks to be installed.
1010

1111
This command will run the following tools:
1212

13-
## black
14-
15-
[black](https://pypi.org/project/black/) is used to format the code, and it is configured through `pyproject.toml`:
16-
17-
```toml
18-
[tool.black]
19-
line-length = 120
20-
include = '\.pyi?$'
21-
target-version = ['py39']
22-
fast = true
23-
```
24-
25-
To exclude directories or files, add an `exclude` argument to `pre-commit-config.yaml`. Note that adding an `exclude` argument to `pyproject.toml`
26-
will not work, see also [here](https://stackoverflow.com/a/61046953/8037249).
27-
2813
## ruff
2914

30-
[ruff](https://github.com/charliermarsh/ruff) is used to check the code style, and it is configured through `pyproject.toml`:
15+
[ruff](https://github.com/charliermarsh/ruff) is used to lint and format the code, and it is configured through `pyproject.toml`:
3116

3217
```
3318
[tool.ruff]

docs/features/makefile.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ available:
77

88
```
99
install Install the poetry environment and install the pre-commit hooks
10-
check Lint and check code by running black, ruff, mypy and deptry.
10+
check Lint and check code by running ruff, mypy and deptry.
1111
test Test the code with pytest
1212
build Build wheel file using poetry
1313
clean-build clean build artifacts

docs/index.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@ This is a modern Cookiecutter template that can be used to initiate a Python pro
2020
- [Poetry](https://python-poetry.org/) for dependency management
2121
- CI/CD with [GitHub Actions](https://github.com/features/actions)
2222
- Pre-commit hooks with [pre-commit](https://pre-commit.com/)
23-
- Code quality with [black](https://pypi.org/project/black/), [ruff](https://github.com/charliermarsh/ruff), [mypy](https://mypy.readthedocs.io/en/stable/), and [deptry](https://github.com/fpgmaas/deptry/)
23+
- Code quality with:
24+
- [ruff](https://github.com/charliermarsh/ruff)
25+
- [mypy](https://mypy.readthedocs.io/en/stable/)
26+
- [deptry](https://github.com/fpgmaas/deptry/)
27+
- [prettier](https://prettier.io/)
2428
- Publishing to [Pypi](https://pypi.org) or [Artifactory](https://jfrog.com/artifactory) by creating a new release on GitHub
2529
- Testing and coverage with [pytest](https://docs.pytest.org/en/7.1.x/) and [codecov](https://about.codecov.io/)
2630
- Documentation with [MkDocs](https://www.mkdocs.org/)
2731
- Compatibility testing for multiple versions of Python with [Tox](https://tox.wiki/en/latest/)
2832
- Containerization with [Docker](https://www.docker.com/)
29-
- Development environment with [VSCode devcontainers](https://code.visualstudio.com/docs/remote/containers)
3033

3134
An example of a repository generated with this package can be found [here](https://github.com/fpgmaas/cookiecutter-poetry-example).
3235

{{cookiecutter.project_name}}/.pre-commit-config.yaml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,12 @@ repos:
99
- id: end-of-file-fixer
1010
- id: trailing-whitespace
1111

12-
- repo: https://github.com/charliermarsh/ruff-pre-commit
13-
rev: "v0.0.230"
12+
- repo: https://github.com/astral-sh/ruff-pre-commit
13+
rev: "v0.1.6"
1414
hooks:
1515
- id: ruff
16-
17-
- repo: https://github.com/psf/black
18-
rev: "22.8.0"
19-
hooks:
20-
- id: black
16+
args: [--exit-non-zero-on-fix]
17+
- id: ruff-format
2118

2219
- repo: https://github.com/pre-commit/mirrors-prettier
2320
rev: "v3.0.3"

{{cookiecutter.project_name}}/pyproject.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ mkdocstrings = {extras = ["python"], version = "^0.23.0"}
3636
requires = ["poetry-core>=1.0.0"]
3737
build-backend = "poetry.core.masonry.api"
3838

39-
[tool.black]
40-
line-length = 120
41-
target-version = ['py37']
42-
preview = true
43-
4439
[tool.mypy]
4540
files = ["{{cookiecutter.project_slug}}"]
4641
disallow_untyped_defs = "True"
@@ -97,6 +92,9 @@ ignore = [
9792
"E731",
9893
]
9994

95+
[tool.ruff.format]
96+
preview = true
97+
10098
{% if cookiecutter.codecov == "y"-%}
10199
[tool.coverage.report]
102100
skip_empty = true

0 commit comments

Comments
 (0)