Skip to content

Commit 3218247

Browse files
[pre-commit.ci] pre-commit autoupdate (#287)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.8.6 → v0.11.4](astral-sh/ruff-pre-commit@v0.8.6...v0.11.4) - [github.com/google/yamlfmt: v0.14.0 → v0.16.0](google/yamlfmt@v0.14.0...v0.16.0) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 1ae9527 commit 3218247

9 files changed

+200
-196
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repos:
1111
- id: check-added-large-files
1212
args: [--maxkb=6000]
1313
- repo: https://github.com/astral-sh/ruff-pre-commit
14-
rev: v0.8.6
14+
rev: v0.11.4
1515
hooks:
1616
# Ruff fix
1717
- id: ruff
@@ -23,7 +23,7 @@ repos:
2323
types_or: [python, pyi]
2424
name: ruff (format)
2525
- repo: https://github.com/google/yamlfmt
26-
rev: v0.14.0
26+
rev: v0.16.0
2727
hooks:
2828
- id: yamlfmt
2929
name: YAML (format)

tutorial/tests/test_basic_datatypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ def test_update_one_dict_with_another(my_dict1, my_dict2, function_to_test):
421421
"ab",
422422
"abc",
423423
"abcd",
424-
"a b c d e" "One two three four five six seven eight nine ten",
424+
"a b c d eOne two three four five six seven eight nine ten",
425425
"Hello world",
426426
"How are you?",
427427
]

tutorial/tests/test_control_flow.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ def reference_range_of_nums(start: int, end: int) -> List[int]:
6262
],
6363
)
6464
def test_range_of_nums(start: int, end: int, function_to_test) -> None:
65-
assert reference_range_of_nums(start, end) == function_to_test(
66-
start, end
67-
), "The function returned an empty range"
65+
assert reference_range_of_nums(start, end) == function_to_test(start, end), (
66+
"The function returned an empty range"
67+
)
6868

6969

7070
def reference_sqrt_of_nums(numbers: List[int]) -> List[float]:
@@ -101,12 +101,12 @@ def reference_sqrt_of_nums(numbers: List[int]) -> List[float]:
101101
def test_sqrt_of_nums(nums: list[int], function_to_test) -> None:
102102
reference, result = reference_sqrt_of_nums(nums), function_to_test(nums)
103103
assert isinstance(result, list), "The function should return a list, not 'None'"
104-
assert len(reference) == len(
105-
result
106-
), "The function should return a list of the same length"
107-
assert all(
108-
isclose(x, y) for x, y in zip(reference, result)
109-
), "The function should return the square root of each number"
104+
assert len(reference) == len(result), (
105+
"The function should return a list of the same length"
106+
)
107+
assert all(isclose(x, y) for x, y in zip(reference, result)), (
108+
"The function should return the square root of each number"
109+
)
110110

111111

112112
def reference_divide_until(number: int) -> int:

tutorial/tests/test_functional_programming.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ def reference_filter_even(my_list: List[int]) -> List[int]:
3939
def test_filter_even(function_to_test: Callable, my_list: List[int]):
4040
res = function_to_test(my_list)
4141
assert isinstance(res, list), "The function you wrote does not return a list"
42-
assert res == reference_filter_even(
43-
my_list
44-
), "The list you return is not equal to the expected solution"
45-
assert not check_for_loop_in_body(
46-
function_to_test
47-
), "You are not allowed to use a for loop in this exercise"
42+
assert res == reference_filter_even(my_list), (
43+
"The list you return is not equal to the expected solution"
44+
)
45+
assert not check_for_loop_in_body(function_to_test), (
46+
"You are not allowed to use a for loop in this exercise"
47+
)
4848

4949

5050
def reference_add_one(my_list: List[int]) -> List[int]:
@@ -60,12 +60,12 @@ def reference_add_one(my_list: List[int]) -> List[int]:
6060
],
6161
)
6262
def test_add_one(function_to_test: Callable, my_list: List[int]):
63-
assert function_to_test(my_list) == reference_add_one(
64-
my_list
65-
), "The list you return is not equal to the expected solution"
66-
assert not check_for_loop_in_body(
67-
function_to_test
68-
), "You are not allowed to use a for loop in this exercise"
63+
assert function_to_test(my_list) == reference_add_one(my_list), (
64+
"The list you return is not equal to the expected solution"
65+
)
66+
assert not check_for_loop_in_body(function_to_test), (
67+
"You are not allowed to use a for loop in this exercise"
68+
)
6969

7070

7171
@pytest.mark.parametrize(

tutorial/tests/test_functions.py

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,19 @@ def test_greet(
4343

4444
# Check number and names of parameters
4545
assert len(params) == 2, "The function should take two arguments."
46-
assert (
47-
"name" in params and "age" in params
48-
), "The function's parameters should be 'name' and 'age'."
46+
assert "name" in params and "age" in params, (
47+
"The function's parameters should be 'name' and 'age'."
48+
)
4949

5050
# Check type hints for parameters
51-
assert all(
52-
p.annotation != inspect.Parameter.empty for p in params.values()
53-
), "The function's parameters should have type hints."
51+
assert all(p.annotation != inspect.Parameter.empty for p in params.values()), (
52+
"The function's parameters should have type hints."
53+
)
5454

5555
# Check return type hint
56-
assert (
57-
return_annotation != inspect.Signature.empty
58-
), "The function's return value is missing the type hint."
56+
assert return_annotation != inspect.Signature.empty, (
57+
"The function's return value is missing the type hint."
58+
)
5959

6060
# Test the return value
6161
assert function_to_test(name, age) == reference_greet(name, age)
@@ -80,15 +80,15 @@ def validate_basic_area_signature(function_to_test) -> None:
8080
return_annotation = signature.return_annotation
8181

8282
assert function_to_test.__doc__ is not None, "The function is missing a docstring."
83-
assert (
84-
len(params) == 2
85-
), "The function should take exactly two arguments (length and width)."
86-
assert all(
87-
p in params.keys() for p in ["length", "width"]
88-
), "The function's parameters should be 'length' and 'width'."
89-
assert all(
90-
p.annotation is float for p in params.values()
91-
), "Both parameters should be annotated as float."
83+
assert len(params) == 2, (
84+
"The function should take exactly two arguments (length and width)."
85+
)
86+
assert all(p in params.keys() for p in ["length", "width"]), (
87+
"The function's parameters should be 'length' and 'width'."
88+
)
89+
assert all(p.annotation is float for p in params.values()), (
90+
"Both parameters should be annotated as float."
91+
)
9292
assert return_annotation is str, "The return type should be annotated as str."
9393

9494

@@ -134,24 +134,24 @@ def validate_metric_area_signature(function_to_test) -> None:
134134
return_annotation = signature.return_annotation
135135

136136
assert function_to_test.__doc__ is not None, "The function is missing a docstring."
137-
assert (
138-
len(params) == 3
139-
), "The function should take three arguments (length, width, and unit)."
140-
assert all(
141-
p in params.keys() for p in ["length", "width", "unit"]
142-
), "The function's parameters should be 'length', 'width' and 'unit'."
143-
assert (
144-
params["length"].annotation is float
145-
), "Parameter 'length' should be annotated as float."
146-
assert (
147-
params["width"].annotation is float
148-
), "Parameter 'width' should be annotated as float."
149-
assert (
150-
params["unit"].annotation is str
151-
), "Parameter 'unit' should be annotated as str."
152-
assert (
153-
params["unit"].default == "cm"
154-
), "Parameter 'unit' should have a default value of 'cm'."
137+
assert len(params) == 3, (
138+
"The function should take three arguments (length, width, and unit)."
139+
)
140+
assert all(p in params.keys() for p in ["length", "width", "unit"]), (
141+
"The function's parameters should be 'length', 'width' and 'unit'."
142+
)
143+
assert params["length"].annotation is float, (
144+
"Parameter 'length' should be annotated as float."
145+
)
146+
assert params["width"].annotation is float, (
147+
"Parameter 'width' should be annotated as float."
148+
)
149+
assert params["unit"].annotation is str, (
150+
"Parameter 'unit' should be annotated as str."
151+
)
152+
assert params["unit"].default == "cm", (
153+
"Parameter 'unit' should have a default value of 'cm'."
154+
)
155155
assert return_annotation is str, "The return type should be annotated as str."
156156

157157

@@ -195,24 +195,24 @@ def validate_area_signature(function_to_test) -> None:
195195
return_annotation = signature.return_annotation
196196

197197
assert function_to_test.__doc__ is not None, "The function is missing a docstring."
198-
assert (
199-
len(params) == 3
200-
), "The function should take three arguments (length, width, and unit)."
201-
assert all(
202-
p in params.keys() for p in ["length", "width", "unit"]
203-
), "The function's parameters should be 'length', 'width' and 'unit'."
204-
assert (
205-
params["length"].annotation is float
206-
), "Parameter 'length' should be annotated as float."
207-
assert (
208-
params["width"].annotation is float
209-
), "Parameter 'width' should be annotated as float."
210-
assert (
211-
params["unit"].annotation is str
212-
), "Parameter 'unit' should be annotated as str."
213-
assert (
214-
params["unit"].default == "cm"
215-
), "Parameter 'unit' should have a default value of 'cm'."
198+
assert len(params) == 3, (
199+
"The function should take three arguments (length, width, and unit)."
200+
)
201+
assert all(p in params.keys() for p in ["length", "width", "unit"]), (
202+
"The function's parameters should be 'length', 'width' and 'unit'."
203+
)
204+
assert params["length"].annotation is float, (
205+
"Parameter 'length' should be annotated as float."
206+
)
207+
assert params["width"].annotation is float, (
208+
"Parameter 'width' should be annotated as float."
209+
)
210+
assert params["unit"].annotation is str, (
211+
"Parameter 'unit' should be annotated as str."
212+
)
213+
assert params["unit"].default == "cm", (
214+
"Parameter 'unit' should have a default value of 'cm'."
215+
)
216216
assert return_annotation is str, "The return type should be annotated as str."
217217

218218

tutorial/tests/test_input_output.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,13 @@ def test_write_file(function_to_test, tmp_path: pl.Path):
9898
function_to_test(tmp_user)
9999
reference_write_file(tmp_test)
100100

101-
assert tmp_user.exists(), """The file was not created. Make sure to create the file in the function. Hint: use `open(output_file, "w")`"""
101+
assert tmp_user.exists(), (
102+
"""The file was not created. Make sure to create the file in the function. Hint: use `open(output_file, "w")`"""
103+
)
102104

103-
assert (
104-
tmp_user.read_text() == tmp_test.read_text()
105-
), "The file content is not correct."
105+
assert tmp_user.read_text() == tmp_test.read_text(), (
106+
"The file content is not correct."
107+
)
106108

107109

108110
def reference_read_write_file(input_file: pl.Path, output_file: pl.Path) -> None:

0 commit comments

Comments
 (0)