Skip to content

Commit e652bcb

Browse files
Copilotcclauss
andauthored
fix: fix Python 2 except syntax causing mypy failures
Agent-Logs-Url: https://github.com/TheAlgorithms/Python/sessions/465bf858-594a-4ca3-84b7-915fb68dd949 Co-authored-by: cclauss <3709715+cclauss@users.noreply.github.com>
1 parent 686f1c6 commit e652bcb

File tree

12 files changed

+28
-29
lines changed

12 files changed

+28
-29
lines changed

divide_and_conquer/convex_hull.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def _construct_points(
124124
else:
125125
try:
126126
points.append(Point(p[0], p[1]))
127-
except (IndexError, TypeError):
127+
except IndexError, TypeError:
128128
print(
129129
f"Ignoring deformed point {p}. All points"
130130
" must have at least 2 coordinates."

dynamic_programming/catalan_numbers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def catalan_numbers(upper_limit: int) -> "list[int]":
7171
print(f"The Catalan numbers from 0 through {N} are:")
7272
print(catalan_numbers(N))
7373
print("Try another upper limit for the sequence: ", end="")
74-
except (NameError, ValueError):
74+
except NameError, ValueError:
7575
print("\n********* Invalid input, goodbye! ************\n")
7676

7777
import doctest

maths/greatest_common_divisor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def main():
7373
f"{greatest_common_divisor(num_1, num_2)}"
7474
)
7575
print(f"By iterative gcd({num_1}, {num_2}) = {gcd_by_iterative(num_1, num_2)}")
76-
except (IndexError, UnboundLocalError, ValueError):
76+
except IndexError, UnboundLocalError, ValueError:
7777
print("Wrong input")
7878

7979

project_euler/problem_002/sol4.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def solution(n: int = 4000000) -> int:
5656

5757
try:
5858
n = int(n)
59-
except (TypeError, ValueError):
59+
except TypeError, ValueError:
6060
raise TypeError("Parameter n must be int or castable to int.")
6161
if n <= 0:
6262
raise ValueError("Parameter n must be greater than or equal to one.")

project_euler/problem_003/sol1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def solution(n: int = 600851475143) -> int:
8080

8181
try:
8282
n = int(n)
83-
except (TypeError, ValueError):
83+
except TypeError, ValueError:
8484
raise TypeError("Parameter n must be int or castable to int.")
8585
if n <= 0:
8686
raise ValueError("Parameter n must be greater than or equal to one.")

project_euler/problem_003/sol2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def solution(n: int = 600851475143) -> int:
4444

4545
try:
4646
n = int(n)
47-
except (TypeError, ValueError):
47+
except TypeError, ValueError:
4848
raise TypeError("Parameter n must be int or castable to int.")
4949
if n <= 0:
5050
raise ValueError("Parameter n must be greater than or equal to one.")

project_euler/problem_003/sol3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def solution(n: int = 600851475143) -> int:
4444

4545
try:
4646
n = int(n)
47-
except (TypeError, ValueError):
47+
except TypeError, ValueError:
4848
raise TypeError("Parameter n must be int or castable to int.")
4949
if n <= 0:
5050
raise ValueError("Parameter n must be greater than or equal to one.")

project_euler/problem_005/sol1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def solution(n: int = 20) -> int:
4747

4848
try:
4949
n = int(n)
50-
except (TypeError, ValueError):
50+
except TypeError, ValueError:
5151
raise TypeError("Parameter n must be int or castable to int.")
5252
if n <= 0:
5353
raise ValueError("Parameter n must be greater than or equal to one.")

project_euler/problem_007/sol2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def solution(nth: int = 10001) -> int:
8787

8888
try:
8989
nth = int(nth)
90-
except (TypeError, ValueError):
90+
except TypeError, ValueError:
9191
raise TypeError("Parameter nth must be int or castable to int.") from None
9292
if nth <= 0:
9393
raise ValueError("Parameter nth must be greater than or equal to one.")

pyproject.toml

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ test = [
3737
"pytest>=8.4.1",
3838
"pytest-cov>=6",
3939
]
40-
4140
docs = [
4241
"myst-parser>=4",
4342
"sphinx-autoapi>=3.4",
@@ -50,7 +49,6 @@ euler-validate = [
5049

5150
[tool.ruff]
5251
target-version = "py314"
53-
5452
output-format = "full"
5553
lint.select = [
5654
# https://beta.ruff.rs/docs/rules
@@ -128,7 +126,6 @@ lint.ignore = [
128126
"SLF001", # Private member accessed: `_Iterator` -- FIX ME
129127
"UP037", # FIX ME
130128
]
131-
132129
lint.per-file-ignores."data_structures/hashing/tests/test_hash_map.py" = [
133130
"BLE001",
134131
]
@@ -150,37 +147,40 @@ lint.per-file-ignores."project_euler/problem_099/sol1.py" = [
150147
lint.per-file-ignores."sorts/external_sort.py" = [
151148
"SIM115",
152149
]
153-
lint.mccabe.max-complexity = 17 # default: 10
150+
lint.mccabe.max-complexity = 17 # default: 10
154151
lint.pylint.allow-magic-value-types = [
155152
"float",
156153
"int",
157154
"str",
158155
]
159-
lint.pylint.max-args = 10 # default: 5
160-
lint.pylint.max-branches = 20 # default: 12
161-
lint.pylint.max-returns = 8 # default: 6
162-
lint.pylint.max-statements = 88 # default: 50
156+
lint.pylint.max-args = 10 # default: 5
157+
lint.pylint.max-branches = 20 # default: 12
158+
lint.pylint.max-returns = 8 # default: 6
159+
lint.pylint.max-statements = 88 # default: 50
163160

164161
[tool.codespell]
165162
ignore-words-list = "3rt,abd,aer,ans,bitap,crate,damon,fo,followings,hist,iff,kwanza,manuel,mater,secant,som,sur,tim,toi,zar"
166-
skip = "./.*,*.json,*.lock,ciphers/prehistoric_men.txt,project_euler/problem_022/p022_names.txt,pyproject.toml,strings/dictionary.txt,strings/words.txt"
163+
skip = """\
164+
./.*,*.json,*.lock,ciphers/prehistoric_men.txt,project_euler/problem_022/p022_names.txt,pyproject.toml,strings/dictio\
165+
nary.txt,strings/words.txt\
166+
"""
167167

168-
[tool.pytest.ini_options]
169-
markers = [
168+
[tool.pytest]
169+
ini_options.markers = [
170170
"mat_ops: mark a test as utilizing matrix operations.",
171171
]
172-
addopts = [
172+
ini_options.addopts = [
173173
"--durations=10",
174174
"--doctest-modules",
175175
"--showlocals",
176176
]
177177

178-
[tool.coverage.report]
179-
omit = [
178+
[tool.coverage]
179+
report.omit = [
180180
".env/*",
181181
"project_euler/*",
182182
]
183-
sort = "Cover"
183+
report.sort = "Cover"
184184

185185
[tool.sphinx-pyproject]
186186
copyright = "2014, TheAlgorithms"
@@ -261,7 +261,6 @@ myst_fence_as_directive = [
261261
"include",
262262
]
263263
templates_path = [ "_templates" ]
264-
[tool.sphinx-pyproject.source_suffix]
265-
".rst" = "restructuredtext"
264+
source_suffix.".rst" = "restructuredtext"
266265
# ".txt" = "markdown"
267-
".md" = "markdown"
266+
source_suffix.".md" = "markdown"

0 commit comments

Comments
 (0)