Skip to content

Commit ba27878

Browse files
committed
Replace pyright with pre-commit
Signed-off-by: Tobias Wolf <[email protected]> On-behalf-of: SAP <[email protected]>
1 parent 2943bac commit ba27878

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1111
-954
lines changed

.pre-commit-config.ruff.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.14.5
4+
hooks:
5+
- id: ruff
6+
args: [ --fix ]
7+
- id: ruff-format

.pre-commit-config.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.14.5
4+
hooks:
5+
- id: ruff
6+
args: [ --fix ]
7+
- id: ruff-format
8+
- repo: https://github.com/pre-commit/pre-commit-hooks
9+
rev: v6.0.0
10+
hooks:
11+
- id: check-yaml
12+
args: [ --allow-multiple-documents ]
13+
- id: check-json
14+
- id: check-toml
15+
- id: check-merge-conflict
16+
- id: mixed-line-ending
17+
- id: end-of-file-fixer
18+
- id: trailing-whitespace
19+
- repo: https://github.com/pre-commit/mirrors-mypy
20+
rev: 'v1.18.2'
21+
hooks:
22+
- id: mypy
23+
args: [--strict, --ignore-missing-imports, --check-untyped-defs]
24+
additional_dependencies:
25+
- types-click
26+
- types-PyYAML
27+
- types-requests

Makefile

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ help:
88
@echo " install - Install the package and dependencies"
99
@echo " install-dev - Install the package and dev dependencies"
1010
@echo " test - Run tests"
11-
@echo " format - Format code with black"
11+
@echo " format - Format code with ruff"
1212
@echo " lint - Run linting checks"
1313
@echo " security - Run security checks with bandit"
1414
@echo " docs - Build the documentation"
@@ -59,24 +59,19 @@ test-trace: install-test
5959
$(POETRY) run pytest -k "not kms" -vvv --log-cli-level=DEBUG
6060

6161
format: install-dev
62-
$(POETRY) run black --extend-exclude test-data/gardenlinux .
62+
$(POETRY) run -c .pre-commit-config.ruff.yaml --all-files
6363

6464
lint: install-dev
65-
@echo
66-
@echo "------------------------------------------------------------------------------------------------------------------------"
67-
@echo "--// BLACK //-----------------------------------------------------------------------------------------------------------"
68-
@echo "------------------------------------------------------------------------------------------------------------------------"
69-
$(POETRY) run black --diff --extend-exclude test-data/gardenlinux .
7065
@echo
7166
@echo "------------------------------------------------------------------------------------------------------------------------"
7267
@echo "--// ISORT //-----------------------------------------------------------------------------------------------------------"
7368
@echo "------------------------------------------------------------------------------------------------------------------------"
7469
$(POETRY) run isort --check-only .
7570
@echo
7671
@echo "------------------------------------------------------------------------------------------------------------------------"
77-
@echo "--// PYRIGHT //---------------------------------------------------------------------------------------------------------"
72+
@echo "--// PRE-COMMIT //------------------------------------------------------------------------------------------------------"
7873
@echo "------------------------------------------------------------------------------------------------------------------------"
79-
$(POETRY) run pyright
74+
$(POETRY) run pre-commit run --all-files
8075

8176
security: install-dev
8277
@if [ "$(CI)" = "true" ]; then \

docs/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,3 @@ Indices and tables
2626
* :ref:`genindex`
2727
* :ref:`modindex`
2828
* :ref:`search`
29-

hack/print_feature_extensions.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
search_and_print_directories() {
55
local pattern="$1"
6-
local base_pattern="${pattern%%.*}"
7-
6+
local base_pattern="${pattern%%.*}"
7+
88
while IFS= read -r file; do
99
dir=$(dirname "$file" | sed 's|^\./||')
10-
10+
1111
suffix="${file##*/}"
12-
suffix="${suffix#"$base_pattern"}"
13-
12+
suffix="${suffix#"$base_pattern"}"
13+
1414
echo "('$dir', '$suffix'),"
1515
done < <(find . -type f -name "$pattern" | sort -u)
1616
}

poetry.lock

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

pyproject.toml

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,26 @@ packages = [{ include = "gardenlinux", from = "src" }]
1010
[tool.poetry.dependencies]
1111
python = ">=3.13"
1212
apt-repo = "^0.5"
13-
boto3 = "^1.40.57"
14-
click = "^8.2.1"
15-
cryptography = "^46.0.1"
13+
boto3 = "^1.41.3"
14+
click = "^8.3.1"
15+
cryptography = "^46.0.3"
1616
jsonschema = "^4.25.1"
17-
networkx = "^3.5"
17+
networkx = "^3.6"
1818
oras = "^0.2.38"
1919
pygit2 = "^1.19.0"
2020
pygments = "^2.19.2"
2121
PyYAML = "^6.0.2"
2222
gitpython = "^3.1.45"
2323

2424
[tool.poetry.group.dev.dependencies]
25-
bandit = "^1.8.6"
26-
black = "^25.1.0"
27-
moto = "^5.1.12"
28-
python-dotenv = "^1.1.1"
29-
pytest = "^9.0.0"
25+
bandit = "^1.9.2"
26+
moto = "^5.1.16"
27+
pre-commit = "^4.5.0"
28+
python-dotenv = "^1.2.1"
29+
pytest = "^8.4.1"
3030
pytest-cov = "^7.0.0"
3131
isort = "^7.0.0"
3232
requests-mock = "^1.12.1"
33-
pyright = "^1.1.403"
3433

3534
[tool.poetry.group.docs.dependencies]
3635
sphinx-rtd-theme = "^3.0.2"
@@ -53,19 +52,6 @@ line_length = 120
5352
known_first_party = ["gardenlinux"]
5453
skip = ["test-data", ".venv", "**/__pycache", ".pytest-cache", "hack"]
5554

56-
[tool.pyright]
57-
typeCheckingMode = "strict"
58-
venvPath = "."
59-
venv = ".venv"
60-
exclude = [
61-
"test-data",
62-
"docs",
63-
"hack",
64-
".venv",
65-
".pytest-cache",
66-
"**/__pycache",
67-
]
68-
6955
[tool.bandit]
7056
skips = ["B101", "B404"] # allow asserts, subprocesses
7157
exclude_dirs = ["tests"]

pyrightconfig.json

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

src/gardenlinux/apt/debsource.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Debsrc:
2121
Apache License, Version 2.0
2222
"""
2323

24-
def __init__(self, deb_source, deb_version):
24+
def __init__(self, deb_source: str, deb_version: str):
2525
"""
2626
Constructor __init__(Debsrc)
2727
@@ -31,8 +31,8 @@ def __init__(self, deb_source, deb_version):
3131
:since: 0.7.0
3232
"""
3333

34-
self.deb_source: str = deb_source
35-
self.deb_version: str = deb_version
34+
self.deb_source = deb_source
35+
self.deb_version = deb_version
3636

3737
def __repr__(self) -> str:
3838
"""

src/gardenlinux/apt/package_repo_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from apt_repo import APTRepository
1010

1111

12-
class GardenLinuxRepo(APTRepository):
12+
class GardenLinuxRepo(APTRepository): # type: ignore[misc]
1313
"""
1414
Class to reflect APT based GardenLinux repositories.
1515

0 commit comments

Comments
 (0)