Skip to content

Commit 7704c16

Browse files
committed
chore: replace black by ruff format
1 parent 2e41575 commit 7704c16

File tree

5 files changed

+72
-134
lines changed

5 files changed

+72
-134
lines changed

.pre-commit-config.yaml

+4-12
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,14 @@ repos:
1414
- id: end-of-file-fixer
1515
- id: trailing-whitespace
1616

17-
# black - formatting
18-
- repo: https://github.com/psf/black
19-
rev: 24.4.2
20-
hooks:
21-
- id: black
22-
name: black
23-
args:
24-
- "--config"
25-
- "./pyproject.toml"
26-
27-
# ruff - linting
17+
# ruff - linting + formatting
2818
- repo: https://github.com/astral-sh/ruff-pre-commit
29-
rev: "v0.4.5"
19+
rev: "v0.4.6"
3020
hooks:
3121
- id: ruff
3222
name: ruff
23+
- id: ruff-format
24+
name: ruff-format
3325

3426
# mypy - lint-like type checking
3527
- repo: https://github.com/pre-commit/mirrors-mypy

poetry.lock

+19-104
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+46-16
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
description = "Python boilerplate"
55
authors = ["Samuel MARLHENS <[email protected]>"]
66
packages = [
7-
{ include = "*", from = "src"}
7+
{ include = "*", from = "src" }
88
]
99
license = "MIT"
1010
readme = "README.md"
@@ -20,11 +20,10 @@ python = "^3.12"
2020
[tool.poetry.dev-dependencies]
2121
pytest = "8.2.1"
2222
pytest-cov = "5.0.0"
23-
black = "24.4.2"
2423
mypy = "1.10.0"
2524
bandit = "1.7.8"
2625
docformatter = "1.7.5"
27-
ruff = "0.4.5"
26+
ruff = "0.4.6"
2827

2928
[build-system]
3029
requires = ["poetry-core>=1.0.0"]
@@ -35,29 +34,60 @@ backend-path = ["src"]
3534
addopts = "-vvv"
3635
testpaths = "tests"
3736

38-
[tool.black]
39-
line_length = 90
40-
target_version = ['py310']
41-
4237
[tool.ruff]
43-
exclude = [
44-
".venv",
45-
".git",
38+
extend-exclude = [
4639
"__pycache__",
4740
"build",
4841
"dist",
49-
"venv",
5042
]
51-
ignore = []
43+
target-version = "py312"
5244
line-length = 90
53-
select = [
45+
src = ["src", "tests"]
46+
47+
[tool.ruff.lint]
48+
extend-select = [
49+
"C4",
50+
"D200",
51+
"D201",
52+
"D204",
53+
"D205",
54+
"D206",
55+
"D210",
56+
"D211",
57+
"D213",
58+
"D300",
59+
"D400",
60+
"D402",
61+
"D403",
62+
"D404",
63+
"D419",
5464
"E",
5565
"F",
56-
"W",
66+
"G010",
5767
"I001",
68+
"INP001",
69+
"N805",
70+
"PERF101",
71+
"PERF102",
72+
"PERF401",
73+
"PERF402",
74+
"PGH004",
75+
"PGH005",
76+
"PIE794",
77+
"PIE796",
78+
"PIE807",
79+
"PIE810",
80+
"RET502",
81+
"RET503",
82+
"RET504",
83+
"RET505",
84+
"RUF015",
85+
"RUF100",
86+
"S101",
87+
"T20",
88+
"W",
5889
]
59-
src = ["src", "tests"]
6090

6191
[mypy]
6292
files = ["src"]
63-
strict_optional = false
93+
strict = "true"

src/myapplication/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ def hello_world():
33

44

55
def main():
6-
print(hello_world())
6+
print(hello_world()) # noqa: T201 print only used as placeholder :)
77

88

99
if __name__ == "__main__":

tests/test_myapplication.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33

44
def test_hello_world():
5-
assert hello_world() == "Hello World"
5+
if hello_world() != "Hello World":
6+
raise ValueError('Expected value to be "Hello World"')

0 commit comments

Comments
 (0)