Skip to content

Commit db68bfe

Browse files
committed
feat: include more pre-commit hooks
This is mostly sync with WeblateOrg/weblate - add shellcheck - add toml sorter - add pyproject linter
1 parent 54cbc09 commit db68bfe

File tree

4 files changed

+66
-48
lines changed

4 files changed

+66
-48
lines changed

.pre-commit-config.yaml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ repos:
4242
hooks:
4343
- id: pretty-format-yaml
4444
args: [--autofix, --indent, '2']
45-
- id: pretty-format-toml
46-
args: [--autofix]
4745
- repo: https://github.com/executablebooks/mdformat
4846
rev: 0.7.22
4947
hooks:
@@ -61,7 +59,20 @@ repos:
6159
rev: v5.0.2
6260
hooks:
6361
- id: reuse
64-
62+
- repo: https://github.com/shellcheck-py/shellcheck-py
63+
rev: v0.10.0.1
64+
hooks:
65+
- id: shellcheck
66+
require_serial: true
67+
args: [-x]
68+
- repo: https://github.com/abravalheri/validate-pyproject
69+
rev: v0.24.1
70+
hooks:
71+
- id: validate-pyproject
72+
- repo: https://github.com/pappasam/toml-sort
73+
rev: v0.24.2
74+
hooks:
75+
- id: toml-sort-fix
6576
- repo: https://github.com/codespell-project/codespell
6677
rev: v2.4.1
6778
hooks:

REUSE.toml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,40 @@ SPDX-PackageSupplier = "Michal Čihař <[email protected]>"
44
version = 1
55

66
[[annotations]]
7-
SPDX-FileCopyrightText = "Michal Čihař <[email protected]>"
8-
SPDX-License-Identifier = "MIT"
97
path = "weblate_language_data/locale/**"
108
precedence = "aggregate"
11-
12-
[[annotations]]
139
SPDX-FileCopyrightText = "Michal Čihař <[email protected]>"
1410
SPDX-License-Identifier = "MIT"
15-
path = "languages-po/**"
16-
precedence = "aggregate"
1711

1812
[[annotations]]
13+
path = "languages-po/**"
14+
precedence = "aggregate"
1915
SPDX-FileCopyrightText = "Michal Čihař <[email protected]>"
2016
SPDX-License-Identifier = "MIT"
21-
path = "**.csv"
22-
precedence = "aggregate"
2317

2418
[[annotations]]
19+
path = "**.csv"
20+
precedence = "aggregate"
2521
SPDX-FileCopyrightText = "Michal Čihař <[email protected]>"
2622
SPDX-License-Identifier = "MIT"
27-
path = ["README.rst", "PLURALS_DIFF.md"]
28-
precedence = "aggregate"
2923

3024
[[annotations]]
25+
path = ["PLURALS_DIFF.md", "README.rst"]
26+
precedence = "aggregate"
3127
SPDX-FileCopyrightText = "Michal Čihař <[email protected]>"
3228
SPDX-License-Identifier = "MIT"
29+
30+
[[annotations]]
3331
path = [
34-
"requirements**.txt",
3532
".gitignore",
3633
".gitmodules",
3734
".weblate",
3835
"MANIFEST.in",
3936
"pyproject.toml",
40-
"setup.cfg",
41-
"REUSE.toml"
37+
"requirements**.txt",
38+
"REUSE.toml",
39+
"setup.cfg"
4240
]
4341
precedence = "aggregate"
42+
SPDX-FileCopyrightText = "Michal Čihař <[email protected]>"
43+
SPDX-License-Identifier = "MIT"

pyproject.toml

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ requires = [
88

99
[project]
1010
authors = [
11-
{name = "Michal Čihař", email = "[email protected]"}
11+
{email = "[email protected]", name = "Michal Čihař"}
1212
]
1313
classifiers = [
1414
"Development Status :: 5 - Production/Stable",
1515
"Intended Audience :: Developers",
1616
"Operating System :: OS Independent",
17-
"Programming Language :: Python",
18-
"Programming Language :: Python :: 3",
1917
"Programming Language :: Python :: 3 :: Only",
20-
"Programming Language :: Python :: 3.9",
21-
"Programming Language :: Python :: 3.9",
18+
"Programming Language :: Python :: 3",
2219
"Programming Language :: Python :: 3.11",
2320
"Programming Language :: Python :: 3.12",
2421
"Programming Language :: Python :: 3.13",
22+
"Programming Language :: Python :: 3.9",
23+
"Programming Language :: Python :: 3.9",
24+
"Programming Language :: Python",
2525
"Topic :: Software Development :: Internationalization",
2626
"Topic :: Software Development :: Localization",
2727
"Topic :: Utilities"
@@ -38,8 +38,8 @@ version = "2025.3"
3838

3939
[project.optional-dependencies]
4040
dev = [
41-
"weblate-language-data[lint,test,types]",
42-
"translate-toolkit==3.15.1"
41+
"translate-toolkit==3.15.1",
42+
"weblate-language-data[lint,test,types]"
4343
]
4444
django = [
4545
"Django"
@@ -50,8 +50,8 @@ lint = [
5050
test = [
5151
]
5252
types = [
53-
"mypy==1.15.0",
54-
"django-stubs==5.1.3"
53+
"django-stubs==5.1.3",
54+
"mypy==1.15.0"
5555
]
5656

5757
[project.readme]
@@ -72,22 +72,22 @@ target-version = ['py39']
7272

7373
[tool.check-manifest]
7474
ignore = [
75-
"LICENSES/*",
76-
"json/*",
77-
"modules/**",
78-
"scripts/*",
79-
".reuse/dep5",
80-
"languages-po/*",
8175
"*.csv",
82-
"Makefile",
83-
".gitmodules",
84-
"scripts/*",
76+
"*.json",
8577
"*.toml",
86-
"*.yml",
8778
"*.yaml",
88-
"*.json",
79+
"*.yml",
8980
".editorconfig",
90-
".weblate"
81+
".gitmodules",
82+
".reuse/dep5",
83+
".weblate",
84+
"json/*",
85+
"languages-po/*",
86+
"LICENSES/*",
87+
"Makefile",
88+
"modules/**",
89+
"scripts/*",
90+
"scripts/*"
9191
]
9292
ignore-bad-ideas = [
9393
"modules/gettext/gettext-tools/tests/*.mo"
@@ -105,29 +105,29 @@ target-version = "py39"
105105

106106
[tool.ruff.lint]
107107
ignore = [
108-
"D10", # TODO: we are missing many docstrings
109-
"PTH", # TODO: Not using pathlib
110-
"EM", # TODO: exception literals
111-
"PERF401", # TODO
112108
"COM812", # CONFIG: trailing newlines
113-
"FBT", # TODO: Boolean in function definition
109+
"D10", # TODO: we are missing many docstrings
114110
"D203", # CONFIG: incompatible with D211
115111
"D212", # CONFIG: incompatible with D213
112+
"E501", # WONTFIX: we accept long strings (rest is formatted by black)
113+
"EM", # TODO: exception literals
114+
"FBT", # TODO: Boolean in function definition
116115
"ISC001", # CONFIG: incompatible with formatter
117-
"TRY003", # WONTFIX: Avoid specifying long messages outside the exception class
118-
"T201", # WONTFIX: using print() (maybe add noqa)
119-
"T203", # WONTFIX: using pprint() (maybe add noqa)
116+
"PERF401", # TODO
117+
"PTH", # TODO: Not using pathlib
120118
"RUF001", # WONTFIX: String contains ambiguous unicode character, we are using Unicode
121119
"RUF012", # TODO: Mutable class attributes should be annotated with `typing.ClassVar`
122-
"E501" # WONTFIX: we accept long strings (rest is formatted by black)
120+
"T201", # WONTFIX: using print() (maybe add noqa)
121+
"T203", # WONTFIX: using pprint() (maybe add noqa)
122+
"TRY003" # WONTFIX: Avoid specifying long messages outside the exception class
123123
]
124124
select = ["ALL"]
125125

126126
[tool.ruff.lint.mccabe]
127127
max-complexity = 16
128128

129129
[tool.ruff.lint.per-file-ignores]
130-
"scripts/*" = ["S607", "S603", "S310", "ANN"]
130+
"scripts/*" = ["ANN", "S310", "S603", "S607"]
131131

132132
[tool.setuptools]
133133
include-package-data = true
@@ -141,3 +141,10 @@ weblate_language_data = "weblate_language_data"
141141
[tool.setuptools.packages.find]
142142
exclude = ["modules*"]
143143
namespaces = true
144+
145+
[tool.tomlsort]
146+
ignore_case = true
147+
sort_inline_arrays = true
148+
sort_inline_tables = true
149+
sort_table_keys = true
150+
spaces_before_inline_comment = 2

scripts/copy-pot-date

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
REGX='^"POT-Creation-Date:.*'
88

99
# Grab date from other branch
10-
REPL=`grep "$REGX" "$1" | sed -e 's/\\\\/\\\\\\\\/'`
10+
REPL=$(grep "$REGX" "$1" | sed -e 's/\\\\/\\\\\\\\/')
1111

1212
# Push it into other files
1313
sed -i -e "s/$REGX/$REPL/" "$2"

0 commit comments

Comments
 (0)