Skip to content

Commit 4d9a2b8

Browse files
authored
Switch from pre-commit to prek (#5037)
1 parent 4751770 commit 4d9a2b8

File tree

10 files changed

+72
-143
lines changed

10 files changed

+72
-143
lines changed

.github/labeler.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ BUILD:
3232
- any-glob-to-any-file:
3333
- ".ci/**/*"
3434
- ".github/**/*"
35-
- ".pre-commit-config.yaml"
36-
- "markdownlint.rb"
35+
- "**/.pre-commit-config.yaml"
3736
- "**/pyproject.toml"
3837
- "**/tox.ini"
3938
- "**/Dockerfile"
39+
- "markdownlint.yaml"
4040
- "MANIFEST.in"
4141

4242
DEPENDENCY:

.markdownlint.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ MD033: false # Inline HTML
2727
# If a page is printed, it helps if the URL is viewable.
2828
MD034: false # Bare URL used
2929

30+
# Either disable this one or MD024 - Multiple headers with the same content.
31+
MD036: false # Emphasis used instead of a header
32+
3033
# fenced-code-language: Fenced code blocks should have a language
3134
MD040: false
3235

3336
# Some md files have comments or links at the top of the files.
3437
MD041: false # First line in file should be a top level header
3538

36-
#===============================================================================
37-
# Exclude rules for pragmatic reasons.
38-
39-
# Either disable this one or MD024 - Multiple headers with the same content.
40-
MD036: false # Emphasis used instead of a header
39+
# Link text like '[here]' is acceptable if the context is descriptive enough.
40+
MD059: false

.pre-commit-config.yaml

Lines changed: 20 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,40 @@
1+
# Pre-commit configuration file for code quality and formatting checks
2+
# In this repository we use 'prek' instead of 'pre-commit' to manage hooks.
3+
# Ensure that 'prek' is installed and used to run these hooks (documentation -> https://github.com/j178/prek).
4+
5+
minimum_prek_version: "0.2.19"
6+
17
default_language_version:
2-
node: 16.15.0
3-
ruby: 2.7.2
8+
node: 24.11.1
49
python: python3.12
510

611
repos:
7-
# yaml formatting
12+
# Ruff - Python linter and formatter
13+
- repo: https://github.com/charliermarsh/ruff-pre-commit
14+
rev: v0.11.13
15+
hooks:
16+
- id: ruff-check
17+
args: [--fix, --unsafe-fixes]
18+
- id: ruff-format
19+
20+
# Prettier - Code formatter for UI files
821
- repo: https://github.com/pre-commit/mirrors-prettier
922
rev: v3.0.3
1023
hooks:
1124
- id: prettier
1225
exclude: ^application/ui/
1326

14-
- repo: https://github.com/pre-commit/mirrors-mypy
15-
rev: "v1.6.1"
16-
hooks:
17-
- id: mypy
18-
alias: mypy_lib
19-
name: mypy (library)
20-
files: '^library/(src/otx)/.*\.py'
21-
additional_dependencies:
22-
[
23-
types-PyYAML,
24-
attrs==21.2.*,
25-
types-aiofiles,
26-
types-requests,
27-
types-Deprecated,
28-
types-docutils,
29-
types_futures,
30-
types-setuptools,
31-
types-python-dateutil,
32-
tokenize-rt==3.2.0,
33-
]
34-
args: [--disallow-untyped-calls, --config-file, library/pyproject.toml]
35-
36-
- repo: https://github.com/pre-commit/mirrors-mypy
37-
rev: "v1.12.0"
38-
hooks:
39-
- id: mypy
40-
alias: mypy_backend
41-
name: mypy (backend)
42-
files: '^application/backend/.*\.py'
43-
additional_dependencies: [types-PyYAML, types-aiofiles, types-requests]
44-
args:
45-
[
46-
--disallow-untyped-calls,
47-
--config-file,
48-
application/backend/pyproject.toml,
49-
]
50-
27+
# Hadolint - Dockerfile linter
5128
- repo: https://github.com/AleksaC/hadolint-py
5229
rev: v2.12.0.3
5330
hooks:
5431
- id: hadolint
55-
name: Lint Dockerfiles
32+
name: hadolint
5633
description: Runs hadolint to lint Dockerfiles
5734

58-
- repo: https://github.com/shellcheck-py/shellcheck-py
59-
rev: v0.9.0.6
60-
hooks:
61-
- id: shellcheck # TODO remove this when all shell scripts have been removed from otx
62-
63-
# markdown linting
35+
# Markdownlint - Markdown linter
6436
- repo: https://github.com/igorshubovych/markdownlint-cli
65-
rev: v0.37.0
37+
rev: v0.46.0
6638
hooks:
6739
- id: markdownlint
6840
args: [--config=.markdownlint.yaml]
69-
70-
# Ruff
71-
- repo: https://github.com/charliermarsh/ruff-pre-commit
72-
rev: v0.11.13
73-
hooks:
74-
- id: ruff-check
75-
args: [--fix, --unsafe-fixes]
76-
- id: ruff-format

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ For those who would like to contribute to the library, see [CONTRIBUTING.md](CON
229229
Thank you! we appreciate your support!
230230

231231
<a href="https://github.com/open-edge-platform/training_extensions/graphs/contributors">
232-
<img src="https://contrib.rocks/image?repo=open-edge-platform/training_extensions" />
232+
<img src="https://contrib.rocks/image?repo=open-edge-platform/training_extensions" alt="Contributors" />
233233
</a>
234234

235235
---
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
default_language_version:
2+
python: python3.13 # Should match the Python version used by the app (set in backend/pyproject.toml)
3+
4+
repos:
5+
- repo: https://github.com/astral-sh/uv-pre-commit
6+
rev: "0.9.7"
7+
hooks:
8+
- id: uv-lock
9+
name: uv lock
10+
- repo: https://github.com/pre-commit/mirrors-mypy
11+
rev: "v1.16.1"
12+
hooks:
13+
- id: mypy
14+
alias: mypy_backend
15+
name: mypy (backend)
16+
additional_dependencies: [types-PyYAML, types-aiofiles, types-requests]
17+
args: [--disallow-untyped-calls, --config-file, pyproject.toml]

application/backend/pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@ mqtt = [
4444

4545
[dependency-groups]
4646
dev = [
47-
"testcontainers~=4.10.0",
4847
"pytest~=8.4",
4948
"pytest-asyncio~=1.1.0",
50-
"types-aiofiles==24.1.0.20240626",
49+
"testcontainers~=4.10.0",
5150
"time-machine~=2.19.0",
5251
]
5352
lint = [
54-
"ruff==0.11.13",
5553
"mypy~=1.16.1",
56-
"types-PyYAML~=6.0.12",
54+
"ruff==0.11.13",
55+
"types-aiofiles~=25.1.0", # should match aiofiles version
5756
"types-requests~=2.32.4",
57+
"types-pyyaml~=6.0.12", # should match pyyaml version
5858
]
5959

6060
[tool.uv]

application/backend/uv.lock

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

library/.pre-commit-config.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
default_language_version:
2+
python: python3.10 # Should match the lowest Python version supported by the library (set in library/pyproject.toml)
3+
4+
repos:
5+
- repo: https://github.com/astral-sh/uv-pre-commit
6+
rev: "0.9.7"
7+
hooks:
8+
- id: uv-lock
9+
name: uv lock
10+
- repo: https://github.com/pre-commit/mirrors-mypy
11+
rev: "v1.6.1"
12+
hooks:
13+
- id: mypy
14+
alias: mypy_lib
15+
name: mypy (library)
16+
files: '^src/otx/.*\.py'
17+
additional_dependencies: [types-PyYAML]
18+
args: [--disallow-untyped-calls, --config-file, pyproject.toml]

library/pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ dependencies = [
5555

5656
[dependency-groups]
5757
dev = [
58-
"pre-commit==4.2.0",
5958
"pytest>=5.3.5",
6059
"pytest-cov>=4.0.0",
6160
"pytest-stress",

library/uv.lock

Lines changed: 0 additions & 69 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)