Skip to content

Commit ae6ba18

Browse files
authored
⬆️🪝 update pre-commit hooks (#48)
<!--pre-commit.ci start--> updates: - [github.com/astral-sh/ruff-pre-commit: v0.7.4 → v0.8.0](astral-sh/ruff-pre-commit@v0.7.4...v0.8.0) - [github.com/henryiii/validate-pyproject-schema-store: 2024.11.18 → 2024.11.22](henryiii/validate-pyproject-schema-store@2024.11.18...2024.11.22) <!--pre-commit.ci end-->
2 parents 27e010c + 806a149 commit ae6ba18

File tree

7 files changed

+168
-159
lines changed

7 files changed

+168
-159
lines changed

.pre-commit-config.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ repos:
5858

5959
# Python linting using ruff
6060
- repo: https://github.com/astral-sh/ruff-pre-commit
61-
rev: v0.7.4
61+
rev: v0.8.1
6262
hooks:
6363
- id: ruff
6464
args: ["--fix", "--show-fixes"]
@@ -86,14 +86,14 @@ repos:
8686

8787
# Format configuration files with prettier
8888
- repo: https://github.com/rbubley/mirrors-prettier
89-
rev: v3.3.3
89+
rev: v3.4.1
9090
hooks:
9191
- id: prettier
9292
types_or: [yaml, markdown, html, css, scss, javascript, json]
9393

9494
# Check for spelling
9595
- repo: https://github.com/crate-ci/typos
96-
rev: typos-dict-v0.11.35
96+
rev: v1.28.1
9797
hooks:
9898
- id: typos
9999

@@ -115,14 +115,14 @@ repos:
115115

116116
# Check JSON schemata
117117
- repo: https://github.com/python-jsonschema/check-jsonschema
118-
rev: 0.29.4
118+
rev: 0.30.0
119119
hooks:
120120
- id: check-dependabot
121121
- id: check-github-workflows
122122
- id: check-readthedocs
123123

124124
# Check the pyproject.toml file
125125
- repo: https://github.com/henryiii/validate-pyproject-schema-store
126-
rev: 2024.11.18
126+
rev: 2024.11.25
127127
hooks:
128128
- id: validate-pyproject

pyproject.toml

+41-44
Original file line numberDiff line numberDiff line change
@@ -158,54 +158,51 @@ unsafe-fixes = true
158158

159159
[tool.ruff.lint]
160160
extend-select = [
161-
"A", # flake8-builtins
162-
"ANN", # flake8-annotations
163-
"ARG", # flake8-unused-arguments
164-
"ASYNC", # flake8-async
165-
"B", "B904", # flake8-bugbear
166-
"C4", # flake8-comprehensions
167-
# "D", # pydocstyle
168-
"EM", # flake8-errmsg
169-
"EXE", # flake8-executable
170-
"FA", # flake8-future-annotations
171-
"FLY", # flynt
172-
"FURB", # refurb
173-
"I", # isort
174-
"ICN", # flake8-import-conventions
175-
"ISC", # flake8-implicit-str-concat
176-
"LOG", # flake8-logging-format
177-
"N", # flake8-naming
178-
"NPY", # numpy
179-
"PERF", # perflint
180-
"PGH", # pygrep-hooks
181-
"PIE", # flake8-pie
182-
"PL", # pylint
183-
"PT", # flake8-pytest-style
184-
"PTH", # flake8-use-pathlib
185-
"PYI", # flake8-pyi
186-
"Q", # flake8-quotes
187-
"RET", # flake8-return
188-
"RSE", # flake8-raise
189-
"RUF", # Ruff-specific
190-
"SLF", # flake8-self
191-
"SLOT", # flake8-slots
192-
"SIM", # flake8-simplify
193-
"TCH", # flake8-type-checking
194-
"TID251", # flake8-tidy-imports.banned-api
195-
"TRY", # tryceratops
196-
"UP", # pyupgrade
197-
"YTT", # flake8-2020
161+
"A", # flake8-builtins
162+
"ANN", # flake8-annotations
163+
"ARG", # flake8-unused-arguments
164+
"ASYNC", # flake8-async
165+
"B", "B904", # flake8-bugbear
166+
"C4", # flake8-comprehensions
167+
# "D", # pydocstyle
168+
"EM", # flake8-errmsg
169+
"EXE", # flake8-executable
170+
"FA", # flake8-future-annotations
171+
"FLY", # flynt
172+
"FURB", # refurb
173+
"I", # isort
174+
"ICN", # flake8-import-conventions
175+
"ISC", # flake8-implicit-str-concat
176+
"LOG", # flake8-logging-format
177+
"N", # flake8-naming
178+
"NPY", # numpy
179+
"PERF", # perflint
180+
"PGH", # pygrep-hooks
181+
"PIE", # flake8-pie
182+
"PL", # pylint
183+
"PT", # flake8-pytest-style
184+
"PTH", # flake8-use-pathlib
185+
"PYI", # flake8-pyi
186+
"Q", # flake8-quotes
187+
"RET", # flake8-return
188+
"RSE", # flake8-raise
189+
"RUF", # Ruff-specific
190+
"SLF", # flake8-self
191+
"SLOT", # flake8-slots
192+
"SIM", # flake8-simplify
193+
"TC", # flake8-type-checking
194+
"TID251", # flake8-tidy-imports.banned-api
195+
"TRY", # tryceratops
196+
"UP", # pyupgrade
197+
"YTT", # flake8-2020
198198
]
199199
ignore = [
200-
"ANN101", # Missing type annotation for `self` in method
201-
"ANN102", # Missing type annotation for `cls` in classmethod
202-
"ISC001", # Conflicts with formatter
203-
"PLR09", # Too many <...>
200+
"ISC001", # Conflicts with formatter
201+
"PLR09", # Too many <...>
204202
"PLR2004", # Magic value used in comparison
205203
"PLC0415", # Import should be at top of file
206-
"PT004", # Incorrect, just usefixtures instead.
207-
"S101", # Use of assert detected
208-
"S404", # `subprocess` module is possibly insecure
204+
"S101", # Use of assert detected
205+
"S404", # `subprocess` module is possibly insecure
209206
]
210207
isort.required-imports = ["from __future__ import annotations"]
211208

scripts/Knapsack/Knapsack.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
from __future__ import annotations
22

33
import locale
4-
import os
54
from pathlib import Path
6-
from typing import cast
5+
from typing import TYPE_CHECKING, cast
76

87
import numpy as np
9-
from sympy import Expr
108

119
# for managing symbols
1210
from mqt.qao import Constraints, ObjectiveFunction, Problem, Solver, Variables
1311

12+
if TYPE_CHECKING:
13+
from sympy import Expr
14+
1415
lambdas_method = [
1516
"upper_bound_only_positive",
1617
"maximum_coefficient",
@@ -44,8 +45,7 @@
4445
("upper lower bound posiform and negaform method", "binary search penalty algorithm"),
4546
]
4647

47-
files = os.listdir("Data/")
48-
for file in files:
48+
for file in Path("Data/").iterdir():
4949
print(file)
5050
with Path("./Data/" + file).open("r", encoding=locale.getpreferredencoding(False)) as f:
5151
lines = f.readlines()
@@ -65,7 +65,7 @@
6565
variables = Variables()
6666
obj = variables.add_binary_variables_array("obj", [objects])
6767
objective_function = ObjectiveFunction()
68-
objective_function.add_objective_function(cast(Expr, np.dot(np.transpose(obj), p_arr)), minimization=False)
68+
objective_function.add_objective_function(cast("Expr", np.dot(np.transpose(obj), p_arr)), minimization=False)
6969
constraint = Constraints()
7070
constraint.add_constraint(str(np.dot(np.transpose(obj), w_arr)) + " <= " + format(W_max))
7171
problem = Problem()
@@ -85,7 +85,7 @@
8585
variables = Variables()
8686
obj = variables.add_binary_variables_array("obj", [objects])
8787
objective_function = ObjectiveFunction()
88-
objective_function.add_objective_function(cast(Expr, np.dot(np.transpose(obj), p_arr)), minimization=False)
88+
objective_function.add_objective_function(cast("Expr", np.dot(np.transpose(obj), p_arr)), minimization=False)
8989
constraint = Constraints()
9090
constraint.add_constraint(str(np.dot(np.transpose(obj), w_arr)) + " <= " + format(W_max))
9191
problem = Problem()

scripts/linear_regression/LinearRegression.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
from __future__ import annotations
22

3-
from typing import cast
3+
from typing import TYPE_CHECKING, cast
44

55
import numpy as np
66
import pandas as pd
77
from sklearn.decomposition import PCA
88
from sklearn.utils import shuffle
9-
from sympy import Expr
109

1110
# for managing symbols
1211
from mqt.qao import Constraints, ObjectiveFunction, Problem, Solver, Variables
1312

13+
if TYPE_CHECKING:
14+
from sympy import Expr
15+
1416
df = pd.read_csv("iris_csv.csv")
1517
df = shuffle(df)
1618
d = len(df.columns) - 1
@@ -48,7 +50,7 @@
4850
objective_function = ObjectiveFunction()
4951
objective_function.add_objective_function(
5052
cast(
51-
Expr,
53+
"Expr",
5254
(
5355
np.dot(np.dot(np.dot(np.transpose(w), np.transpose(X_training)), X_training), w)
5456
- 2 * np.dot(np.dot(np.transpose(w), np.transpose(X_training)), Y_training)

0 commit comments

Comments
 (0)