Skip to content

Commit 014b9fd

Browse files
ianardeeCopilot
andcommitted
Update cache path for pre-commit workflow
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent ec61547 commit 014b9fd

9 files changed

Lines changed: 42 additions & 22 deletions

File tree

‎.editorconfig‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
9+
[*.{json,txt,toml}]
10+
indent_style = space
11+
indent_size = 2
12+
13+
[*.{md,markdown}]
14+
trim_trailing_whitespace = false

‎.gitattributes‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# These files are always considered text and should use LF.
55
# See core.whitespace @ https://git-scm.com/docs/git-config for whitespace flags.
66
*.py text eol=lf whitespace=blank-at-eol,space-before-tab,tab-in-indent,tabwidth=4 diff=python
7+
*.json text eol=lf whitespace=blank-at-eol,space-before-tab,tab-in-indent,tabwidth=2
78
*.sh text eol=lf whitespace=blank-at-eol diff=bash
89
*.md text eol=lf whitespace=blank-at-eol diff=markdown
910
*.rst text eol=lf whitespace=blank-at-eol

‎.github/workflows/_static-analysis.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
- name: Cache pre-commit
5151
uses: actions/cache@v6
5252
with:
53-
path: ~/.cache/pre-commit
53+
path: ~/.cache/prek
5454
key: ${{ runner.os }}-prec-${{ hashFiles('prek.toml') }}
5555
restore-keys: |
5656
${{ runner.os }}-prec-

‎.github/workflows/_test-integrations.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ jobs:
100100
101101
- name: Install dependencies
102102
run: |
103-
pip install toml
103+
pip install 'tomli~=2.4.1' 'tomli-w~=1.2.0'
104104
python scripts/generate_lite_toml.py
105105
mv -f pyproject-lite.toml pyproject.toml
106106
pip install -e '.[test]'

‎.github/workflows/_test-units.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,12 @@ jobs:
8181
8282
- name: Install dependencies
8383
run: |
84-
pip install toml
84+
pip install 'tomli~=2.4.1' 'tomli-w~=1.2.0'
8585
python scripts/generate_lite_toml.py
8686
mv -f pyproject-lite.toml pyproject.toml
8787
pip install -e '.[test]'
8888
shell: bash
89+
8990
- name: Unit testing with pytest
9091
run: |
9192
pytest

‎prek.toml‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
#:schema https://www.schemastore.org/prek.json
44

55
[[repos]]
6-
repo = "https://github.com/charliermarsh/ruff-pre-commit"
6+
repo = "https://github.com/astral-sh/ruff-pre-commit"
77
rev = "v0.16.9"
88
hooks = [
99
{
1010
id = "ruff-check",
1111
args = [
1212
"--fix",
13-
"--exit-non-zero-on-fix"
13+
"--exit-non-zero-on-fix",
1414
]
1515
},
1616
{ id = "ruff-format" }
@@ -33,7 +33,7 @@ hooks = [
3333
entry = "pylint",
3434
language = "system",
3535
types = ["python"],
36-
args = ["-j2"]
36+
args = ["-j2"],
3737
}
3838
]
3939

@@ -45,7 +45,7 @@ hooks = [
4545
id = "pip-audit",
4646
args = ["."],
4747
files = '^(requirements.*\.txt|setup\.cfg|setup\.py|pyproject\.toml)$',
48-
stages = ["pre-push"]
48+
stages = ["pre-push"],
4949
}
5050
]
5151

@@ -55,15 +55,15 @@ rev = "v2.3.1"
5555
hooks = [
5656
{
5757
id = "mypy",
58-
args = [
59-
],
58+
args = [ ],
6059
exclude = "tests/|examples/|docs/",
6160
additional_dependencies = [
6261
"httpx",
6362
"types-setuptools",
6463
"importlib-metadata",
6564
"types-Pillow",
66-
"types-toml"
65+
"tomli",
66+
"tomli_w",
6767
]
6868
}
6969
]
@@ -78,7 +78,7 @@ hooks = [
7878
language = "system",
7979
pass_filenames = false,
8080
files = '^docs/.*$|^mindee/.*\.py$',
81-
stages = ["pre-push"]
81+
stages = ["pre-push"],
8282
},
8383
{
8484
id = "sphinx-linkcheck",
@@ -87,6 +87,6 @@ hooks = [
8787
language = "system",
8888
pass_filenames = false,
8989
files = '^docs/.*$|^mindee/.*\.py$',
90-
stages = ["pre-push"]
90+
stages = ["pre-push"],
9191
}
9292
]

‎pyproject.toml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ lint = [
4747
"pip-audit==2.10.1",
4848
]
4949
test = [
50-
"toml~=0.10.2",
50+
"tomli~=2.4.1",
5151
"pytest>=9.0.3,<9.2.0",
5252
"pytest-cov~=7.1.0",
5353
"respx~=0.23.1"
@@ -60,7 +60,8 @@ docs = [
6060
build = [
6161
"build",
6262
"twine",
63-
"toml"
63+
"tomli~=2.4.1",
64+
"tomli-w~=1.2.0"
6465
]
6566

6667
[project.scripts]

‎scripts/generate_lite_toml.py‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
from typing import Any
22

3-
import toml
3+
import tomli
4+
import tomli_w
45

56

67
def generate_lite() -> None:
78
"""Generates the mindee-lite version of pyproject.toml"""
8-
with open("pyproject.toml", encoding="utf-8") as file_data:
9-
data: dict[str, Any] = toml.load(file_data)
9+
with open("pyproject.toml", encoding="utf-8") as read_handle:
10+
data: dict[str, Any] = tomli.loads(read_handle.read())
1011

1112
data["project"]["name"] = "mindee-lite"
1213
data["project"]["description"] = (
@@ -32,8 +33,8 @@ def generate_lite() -> None:
3233
"ini_options"
3334
]["addopts"].replace(" lite", " pypdfium2 and not pillow")
3435

35-
with open("pyproject-lite.toml", "w", encoding="utf-8") as file_data:
36-
toml.dump(data, file_data)
36+
with open("pyproject-lite.toml", "w", encoding="utf-8") as write_handle:
37+
write_handle.write(tomli_w.dumps(data))
3738

3839
print("Successfully generated pyproject-lite.toml")
3940

‎tests/test_pkg_versions.py‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import re
44
from pathlib import Path
55

6-
import toml
6+
import tomli
77

88

99
def _test_version(versions_a, versions_b, key):
@@ -12,7 +12,9 @@ def _test_version(versions_a, versions_b, key):
1212

1313
def test_style_pkg_versions():
1414
"""Check black, flake8, isort and pydocstyle versions consistency."""
15-
config = toml.load(Path(__file__).parent.parent.joinpath("pyproject.toml"))
15+
config = tomli.loads(
16+
Path(__file__).parent.parent.joinpath("pyproject.toml").read_text()
17+
)
1618
line_sep = re.compile(r"(==|~=|>=)")
1719
requirements_versions = {}
1820
for line in config["project"]["optional-dependencies"]["lint"]:
@@ -21,7 +23,7 @@ def test_style_pkg_versions():
2123

2224
# Get pre-commit versions
2325
pre_commit_versions = {}
24-
config = toml.load(Path(__file__).parent.parent.joinpath("prek.toml"))
26+
config = tomli.loads(Path(__file__).parent.parent.joinpath("prek.toml").read_text())
2527
for repo in config["repos"]:
2628
if not repo.get("rev"):
2729
continue

0 commit comments

Comments
 (0)