Skip to content

Commit eb6115f

Browse files
committed
chore: update linting rules
1 parent de4dc35 commit eb6115f

File tree

9 files changed

+136
-578
lines changed

9 files changed

+136
-578
lines changed

hooks/pre-commit.json

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,31 @@
11
{
22
"steps": [
3-
{
4-
"from": "py-black"
5-
},
63
{
74
"from": "py-mypy"
85
},
96
{
107
"from": "py-pytest"
118
},
129
{
13-
"from": "py-ruff"
10+
"from": "py-ruff-lint"
11+
},
12+
{
13+
"from": "py-ruff-format"
1414
},
1515
{
1616
"from": "py-yamllint"
1717
},
1818
{
1919
"from": "py-mdformat"
20+
},
21+
{
22+
"from": "py-typeddict"
23+
},
24+
{
25+
"from": "py-dataclass"
26+
},
27+
{
28+
"from": "py-literal"
2029
}
2130
]
2231
}

hooks/shared/py-black.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

hooks/shared/py-dataclass.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "python: disallow @dataclass",
3+
"command": "git grep -q --untracked -I -e '@dataclass' -- '*.py' && { echo '❌ Lint failed: @dataclass is not allowed. Use pydantic.BaseModel instead.'; exit 1; } || true",
4+
"onlyOn": "**/*.py"
5+
}

hooks/shared/py-literal.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "python: disallow TypedDict",
3+
"command": "git grep -q --untracked -I -e 'Literal' -- '*.py' && { echo '❌ Lint failed: Literal is not allowed. Use enum.StrEnum instead.'; exit 1; } || true",
4+
"onlyOn": "**/*.py"
5+
}

hooks/shared/py-ruff-format.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "python: ruff format",
3+
"command": "poetry run ruff format check app tests",
4+
"onlyOn": "**/*.py"
5+
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "python: ruff",
2+
"name": "python: ruff lint",
33
"command": "poetry run ruff check app tests",
44
"onlyOn": "**/*.py"
55
}

hooks/shared/py-typeddict.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "python: disallow TypedDict",
3+
"command": "git grep -q --untracked -I -e 'TypedDict' -- '*.py' && { echo '❌ Lint failed: TypedDict is not allowed. Use pydantic.BaseModel instead.'; exit 1; } || true",
4+
"onlyOn": "**/*.py"
5+
}

poetry.lock

Lines changed: 1 addition & 465 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 101 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,29 @@
11
[build-system]
2-
requires = [ "poetry-core>=1.0.0",]
2+
requires = ["poetry-core>=1.0.0"]
33
build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "app"
77
version = "1.0.0"
88
description = "Escape Python Template Project"
9-
authors = [ "Escape Technologies SAS <[email protected]>",]
10-
maintainers = [ "Swan <[email protected]>", "Antoine Carossio <[email protected]>",]
9+
authors = ["Escape Technologies SAS <[email protected]>"]
10+
maintainers = ["Antoine Carossio <[email protected]>"]
1111
license = "MIT"
1212
readme = "README.md"
1313
homepage = "https://escape.tech/"
1414
repository = "https://github.com/Escape-Technologies/python-project-template"
1515
[[tool.poetry.packages]]
1616
include = "app"
1717

18-
[tool.black]
19-
line-length = 120
20-
skip-string-normalization = true
21-
22-
[tool.ruff]
23-
unfixable = [ "F841",]
24-
select = [ "F", "E", "W", "C90", "I", "YTT", "S", "B", "COM", "C4", "ISC", "ICN", "INP", "PIE", "T20", "PYI", "PT", "Q", "RSE", "RET", "TID", "ARG", "PGH", "PL", "PLC", "PLE", "PLR", "PLW", "NPY", "RUF", "TD002", "TD004", "TD005", "TD007",]
25-
exclude = [ ".venv", "poetry.lock", "__pycache__", "pyproject.toml",]
26-
ignore = [ "E999", "UP015", "S311",]
27-
line-length = 160
28-
target-version = "py311"
29-
ignore-init-module-imports = true
30-
task-tags = [ "TODO",]
31-
32-
[tool.mypy]
33-
python_version = "3.12"
34-
disallow_untyped_defs = true
35-
disallow_untyped_calls = true
36-
disallow_incomplete_defs = true
37-
disallow_untyped_decorators = true
38-
no_implicit_optional = false
39-
strict_equality = true
40-
show_error_codes = true
41-
warn_unreachable = true
42-
warn_redundant_casts = true
43-
warn_unused_ignores = true
44-
warn_unused_configs = true
45-
namespace_packages = true
46-
pretty = true
47-
files = "app, tests"
48-
exclude = [ ".venv", "setup.py", ".git", ".tox", "dist", "build", "docs", "node_modules", "__pycache__",]
49-
[[tool.mypy.overrides]]
50-
module = "opentelemetry.*"
51-
ignore_missing_imports = true
52-
53-
[[tool.mypy.overrides]]
54-
module = "networkx.*"
55-
ignore_missing_imports = true
56-
57-
[[tool.mypy.overrides]]
58-
module = "boto3.*"
59-
ignore_missing_imports = true
60-
61-
[[tool.mypy.overrides]]
62-
module = "botocore.*"
63-
ignore_missing_imports = true
64-
65-
[[tool.mypy.overrides]]
66-
module = "confluent_kafka.*"
67-
ignore_missing_imports = true
68-
69-
[[tool.mypy.overrides]]
70-
module = "aenum.*"
71-
ignore_missing_imports = true
72-
73-
[[tool.mypy.overrides]]
74-
module = "pydash.*"
75-
ignore_missing_imports = true
76-
7718
[tool.poetry.scripts]
7819
app-cli = "app:main"
7920

8021
[tool.poetry.dependencies]
8122
python = ">=3.10,<=3.14"
8223
pydantic = "*"
8324

84-
[tool.coverage.run]
85-
parallel = true
86-
omit = [ "_test.py",]
87-
88-
[tool.pytest.ini_options]
89-
addopts = []
90-
filterwarnings = [ "ignore:Module already imported.*:pytest.PytestAssertRewriteWarning", "ignore::DeprecationWarning",]
91-
92-
[tool.ruff.per-file-ignores]
93-
"__init__.py" = [ "F401", "F403",]
94-
"*_test.py" = [ "S101",]
95-
"*/test/*" = [ "INP001",]
96-
"*/scripts/*" = [ "INP001",]
97-
"*test_*.py" = [ "S101",]
98-
99-
[tool.ruff.pydocstyle]
100-
convention = "google"
101-
102-
[tool.ruff.flake8-quotes]
103-
docstring-quotes = "double"
104-
inline-quotes = "single"
105-
106-
[tool.ruff.pylint]
107-
max-branches = 15
108-
max-args = 10
109-
110-
[tool.ruff.pycodestyle]
111-
max-doc-length = 160
112-
ignore-overlong-task-comments = true
113-
114-
[tool.ruff.mccabe]
115-
max-complexity = 15
116-
11725
[tool.poetry.group.dev.dependencies]
118-
flake8 = "*"
11926
mypy = "*"
120-
pydot = "*"
12127
ruff = "*"
12228
toml = "*"
12329
pytest = "*"
@@ -136,10 +42,102 @@ ipykernel = "*"
13642
mdformat = "*"
13743
gitlint = "*"
13844

139-
[tool.poetry.group.dev.dependencies.black]
140-
version = "*"
141-
extras = [ "jupyter",]
14245

143-
[tool.poetry.group.dev.dependencies.betterproto]
144-
version = "*"
145-
extras = [ "compiler",]
46+
########################################################
47+
####################### Ruff ###########################
48+
########################################################
49+
50+
[tool.ruff]
51+
exclude = [".venv", "poetry.lock", "__pycache__", "pyproject.toml"]
52+
line-length = 120
53+
target-version = "py312"
54+
55+
[tool.ruff.lint]
56+
unfixable = ["F841"]
57+
ignore = ["UP015", "S311", "PYI041"]
58+
task-tags = ["TODO"]
59+
select = ["ALL"]
60+
61+
[tool.ruff.lint.pydocstyle]
62+
convention = "google"
63+
64+
[tool.ruff.format]
65+
quote-style = "preserve"
66+
67+
[tool.ruff.lint.flake8-quotes]
68+
docstring-quotes = "double"
69+
inline-quotes = "single"
70+
71+
[tool.ruff.lint.per-file-ignores]
72+
"__init__.py" = [
73+
"F401", # Module imported but unused
74+
"F403", # 'from module import *' used; unable to detect undefined names
75+
]
76+
"*/test/*" = [
77+
"INP001",
78+
] # As part of an implicit namespace package, missing __init__ file
79+
"*/scripts/*" = [
80+
"INP001",
81+
] # As part of an implicit namespace package, missing __init__ file
82+
"*_test.py" = ["S101"] # Do not use assert statements
83+
"*test_*.py" = ["S101"]
84+
85+
[tool.ruff.lint.pylint]
86+
max-args = 4
87+
max-branches = 5
88+
max-statements = 5
89+
90+
[tool.ruff.lint.pycodestyle]
91+
max-doc-length = 160
92+
ignore-overlong-task-comments = true
93+
94+
[tool.ruff.lint.mccabe]
95+
max-complexity = 10
96+
97+
########################################################
98+
####################### MyPy ###########################
99+
########################################################
100+
101+
[tool.mypy]
102+
python_version = "3.12"
103+
disallow_untyped_defs = true
104+
disallow_untyped_calls = true
105+
disallow_incomplete_defs = true
106+
disallow_untyped_decorators = true
107+
no_implicit_optional = false
108+
strict_equality = true
109+
show_error_codes = true
110+
warn_unreachable = true
111+
warn_redundant_casts = true
112+
warn_unused_ignores = true
113+
warn_unused_configs = true
114+
namespace_packages = true
115+
pretty = true
116+
files = "app, tests"
117+
exclude = [
118+
".venv",
119+
"setup.py",
120+
".git",
121+
".tox",
122+
"dist",
123+
"build",
124+
"docs",
125+
"node_modules",
126+
"__pycache__",
127+
]
128+
129+
130+
########################################################
131+
####################### Pytest #########################
132+
########################################################
133+
134+
[tool.coverage.run]
135+
parallel = true
136+
omit = ["_test.py"]
137+
138+
[tool.pytest.ini_options]
139+
addopts = []
140+
filterwarnings = [
141+
"ignore:Module already imported.*:pytest.PytestAssertRewriteWarning",
142+
"ignore::DeprecationWarning",
143+
]

0 commit comments

Comments
 (0)