Skip to content

Commit 4bbaa7c

Browse files
MImmesbergerclaude
andcommitted
Fix linting errors in test files
- Add match parameter to pytest.raises for more specific exception testing - Move imports to top-level of test files - Add noqa comments for intentionally unused function arguments - Remove unused variable assignment Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent a54cd44 commit 4bbaa7c

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

tests/interface_dag_elements/test_dates.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66

77
from ttsim.interface_dag_elements.dates import (
88
evaluation_date_from_evaluation_date_str,
9+
evaluation_date_str,
910
evaluation_date_use_other_info,
1011
policy_date,
12+
policy_date_str,
1113
)
1214
from ttsim.interface_dag_elements.interface_node_objects import (
1315
InputDependentInterfaceFunction,
@@ -52,7 +54,7 @@ def test_policy_date_various_valid_dates(date_str):
5254

5355

5456
def test_policy_date_invalid_date_raises():
55-
with pytest.raises(ValueError):
57+
with pytest.raises(ValueError, match="day is out of range for month"):
5658
policy_date("2024-02-30") # Invalid date
5759

5860

@@ -157,15 +159,11 @@ def test_evaluation_date_from_str_condition_not_satisfied_when_no_eval_date_str(
157159
# Input definitions tests
158160
# =============================================================================
159161
def test_policy_date_str_is_interface_input():
160-
from ttsim.interface_dag_elements.dates import policy_date_str
161-
162162
assert isinstance(policy_date_str, InterfaceInput)
163163
assert policy_date_str.in_top_level_namespace is True
164164

165165

166166
def test_evaluation_date_str_is_interface_input():
167-
from ttsim.interface_dag_elements.dates import evaluation_date_str
168-
169167
assert isinstance(evaluation_date_str, InterfaceInput)
170168
assert evaluation_date_str.in_top_level_namespace is True
171169

tests/interface_dag_elements/test_interface_node_objects.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def my_func(x: int) -> int:
127127

128128
def test_interface_function_dependencies_property():
129129
@interface_function()
130-
def my_func(a: int, b: str, c: float) -> int:
130+
def my_func(a: int, b: str, c: float) -> int: # noqa: ARG001
131131
return a
132132

133133
assert my_func.dependencies == {"a", "b", "c"}
@@ -143,7 +143,7 @@ def original_name(x: int) -> int:
143143

144144
def test_interface_function_preserves_signature():
145145
@interface_function()
146-
def my_func(a: int, b: str = "default") -> int:
146+
def my_func(a: int, b: str = "default") -> int: # noqa: ARG001
147147
return a
148148

149149
sig = inspect.signature(my_func)

tests/interface_dag_elements/test_labels.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import networkx as nx
4+
import numpy as np
45
import pytest
56

67
from ttsim.interface_dag_elements.labels import (
@@ -128,8 +129,6 @@ def test_input_columns_from_input_data_empty():
128129
# input_columns_is_empty_set tests
129130
# =============================================================================
130131
def test_input_columns_is_empty_set_returns_empty():
131-
import numpy as np
132-
133132
result = input_columns_is_empty_set(xnp=np)
134133
assert result == set()
135134

tests/interface_dag_elements/test_raw_results.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def tt_function(data):
4848
call_args.append(data)
4949
return {"output": xnp.array([1, 2])}
5050

51-
result = columns(
51+
columns(
5252
labels__root_nodes=root_nodes,
5353
processed_data=processed_data,
5454
tt_function=tt_function,

0 commit comments

Comments
 (0)