Skip to content

Commit 272c7fd

Browse files
author
lilydu
committed
fix mypy checks
1 parent a5972a2 commit 272c7fd

File tree

4 files changed

+32
-32
lines changed

4 files changed

+32
-32
lines changed

packages/common/src/common/logging/test_filter.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@
99
from .filter import ConsoleFilter
1010

1111

12-
def test_default_pattern():
12+
def test_default_pattern() -> None:
1313
filter = ConsoleFilter()
1414
record = MagicMock(spec=logging.LogRecord)
1515
record.name = "test"
1616

1717
assert filter.filter(record) is True
1818

1919

20-
def test_exact_match():
20+
def test_exact_match() -> None:
2121
filter = ConsoleFilter("test")
2222
record = MagicMock(spec=logging.LogRecord)
2323
record.name = "test"
2424

2525
assert filter.filter(record) is True
2626

2727

28-
def test_wildcard_prefix():
28+
def test_wildcard_prefix() -> None:
2929
filter = ConsoleFilter("test*")
3030

3131
matching_record = MagicMock(spec=logging.LogRecord)
@@ -37,7 +37,7 @@ def test_wildcard_prefix():
3737
assert filter.filter(non_matching_record) is False
3838

3939

40-
def test_wildcard_suffix():
40+
def test_wildcard_suffix() -> None:
4141
filter = ConsoleFilter("*test")
4242

4343
matching_record = MagicMock(spec=logging.LogRecord)
@@ -49,7 +49,7 @@ def test_wildcard_suffix():
4949
assert filter.filter(non_matching_record) is False
5050

5151

52-
def test_wildcard_middle():
52+
def test_wildcard_middle() -> None:
5353
filter = ConsoleFilter("my*test")
5454

5555
matching_record = MagicMock(spec=logging.LogRecord)
@@ -61,7 +61,7 @@ def test_wildcard_middle():
6161
assert filter.filter(non_matching_record) is False
6262

6363

64-
def test_multiple_wildcards():
64+
def test_multiple_wildcards() -> None:
6565
filter = ConsoleFilter("my*log*test")
6666

6767
matching_record = MagicMock(spec=logging.LogRecord)
@@ -73,7 +73,7 @@ def test_multiple_wildcards():
7373
assert filter.filter(partial_match_record) is False
7474

7575

76-
def test_case_sensitivity():
76+
def test_case_sensitivity() -> None:
7777
filter = ConsoleFilter("Test")
7878

7979
upper_record = MagicMock(spec=logging.LogRecord)

packages/common/src/common/logging/test_formatter.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
"""
55

66
import logging
7-
from typing import Union
7+
from typing import Collection, Union
88

99
from .ansi import ANSI
1010
from .formatter import ConsoleFormatter
1111

1212

13-
def create_record(name: str, level: int, msg: Union[str, dict, list]) -> logging.LogRecord:
13+
def create_record(name: str, level: int, msg: Union[str, dict[str, Collection[str]], list[Collection[str]]]) -> logging.LogRecord:
1414
record = logging.LogRecord(name=name, level=level, pathname="test.py", lineno=1, msg=msg, args=(), exc_info=None)
1515
record.levelname = logging.getLevelName(level)
1616
return record
1717

1818

19-
def test_error_formatting():
19+
def test_error_formatting() -> None:
2020
formatter = ConsoleFormatter()
2121
record = create_record("test", logging.ERROR, "Error message")
2222

@@ -25,7 +25,7 @@ def test_error_formatting():
2525
assert result == expected
2626

2727

28-
def test_warning_formatting():
28+
def test_warning_formatting() -> None:
2929
formatter = ConsoleFormatter()
3030
record = create_record("test", logging.WARNING, "Warning message")
3131

@@ -36,7 +36,7 @@ def test_warning_formatting():
3636
assert result == expected
3737

3838

39-
def test_info_formatting():
39+
def test_info_formatting() -> None:
4040
formatter = ConsoleFormatter()
4141
record = create_record("test", logging.INFO, "Info message")
4242

@@ -45,7 +45,7 @@ def test_info_formatting():
4545
assert result == expected
4646

4747

48-
def test_debug_formatting():
48+
def test_debug_formatting() -> None:
4949
formatter = ConsoleFormatter()
5050
record = create_record("test", logging.DEBUG, "Debug message")
5151

@@ -54,7 +54,7 @@ def test_debug_formatting():
5454
assert result == expected
5555

5656

57-
def test_dict_message_formatting():
57+
def test_dict_message_formatting() -> None:
5858
formatter = ConsoleFormatter()
5959
dict_msg = {"key": "value", "nested": {"inner": "data"}}
6060
record = create_record("test", logging.INFO, dict_msg)
@@ -69,7 +69,7 @@ def test_dict_message_formatting():
6969
assert '"inner": "data"' in result
7070

7171

72-
def test_list_message_formatting():
72+
def test_list_message_formatting() -> None:
7373
formatter = ConsoleFormatter()
7474
list_msg = ["item1", "item2", {"key": "value"}]
7575
record = create_record("test", logging.INFO, list_msg)
@@ -84,7 +84,7 @@ def test_list_message_formatting():
8484
assert '"key": "value"' in result
8585

8686

87-
def test_multiline_message_formatting():
87+
def test_multiline_message_formatting() -> None:
8888
formatter = ConsoleFormatter()
8989
multiline_msg = "Line 1\nLine 2\nLine 3"
9090
record = create_record("test", logging.INFO, multiline_msg)
@@ -99,7 +99,7 @@ def test_multiline_message_formatting():
9999
assert result == expected
100100

101101

102-
def test_unknown_level_formatting():
102+
def test_unknown_level_formatting() -> None:
103103
formatter = ConsoleFormatter()
104104
record = create_record("test", 123, "Custom level message")
105105

packages/common/src/common/storage/test_list_local_storage.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
from .list_local_storage import ListLocalStorage
77

88

9-
def test_get_undefined_empty_index():
10-
storage = ListLocalStorage()
9+
def test_get_undefined_empty_index() -> None:
10+
storage: ListLocalStorage[int] = ListLocalStorage()
1111
assert storage.get(0) is None
1212

1313

14-
def test_push_and_get():
14+
def test_push_and_get() -> None:
1515
storage = ListLocalStorage[int]()
1616
storage.append(1)
1717
storage.append(2)
@@ -20,39 +20,39 @@ def test_push_and_get():
2020
assert storage.length() == 2
2121

2222

23-
def test_set_and_overwrite():
23+
def test_set_and_overwrite() -> None:
2424
storage = ListLocalStorage[int]([1, 2, 3])
2525
storage.set(1, 42)
2626
assert storage.get(1) == 42
2727
assert storage.items() == [1, 42, 3]
2828

2929

30-
def test_delete_by_index():
30+
def test_delete_by_index() -> None:
3131
storage = ListLocalStorage[int]([1, 2, 3])
3232
storage.delete(1)
3333
assert storage.items() == [1, 3]
3434
assert storage.length() == 2
3535

3636

37-
def test_pop():
37+
def test_pop() -> None:
3838
storage = ListLocalStorage[int]([1, 2, 3])
3939
assert storage.pop() == 3
4040
assert storage.items() == [1, 2]
4141
assert storage.length() == 2
4242

4343

44-
def test_get_all_values():
44+
def test_get_all_values() -> None:
4545
storage = ListLocalStorage[int]([1, 2, 3])
4646
assert storage.items() == [1, 2, 3]
4747

4848

49-
def test_filter_with_where():
49+
def test_filter_with_where() -> None:
5050
storage = ListLocalStorage[int]([1, 2, 3, 4])
5151
even = storage.filter(lambda v, i: v % 2 == 0)
5252
assert even == [2, 4]
5353

5454

55-
def test_mixed_operations():
55+
def test_mixed_operations() -> None:
5656
storage = ListLocalStorage[str]()
5757
storage.append("a")
5858
storage.append("b")

packages/common/src/common/storage/test_local_storage.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@
66
from .local_storage import LocalStorage, LocalStorageOptions
77

88

9-
def test_get_undefined():
10-
storage = LocalStorage()
9+
def test_get_undefined() -> None:
10+
storage: LocalStorage[int] = LocalStorage()
1111
assert storage.get("test") is None
1212

1313

14-
def test_set_get_delete():
15-
storage = LocalStorage()
14+
def test_set_get_delete() -> None:
15+
storage: LocalStorage[str] = LocalStorage()
1616
storage.set("testing", "123")
1717
assert storage.get("testing") == "123"
1818
storage.delete("testing")
1919
assert storage.get("testing") is None
2020

2121

22-
def test_max_size():
23-
storage = LocalStorage(options=LocalStorageOptions(max=3))
22+
def test_max_size() -> None:
23+
storage: LocalStorage[int] = LocalStorage(options=LocalStorageOptions(max=3))
2424

2525
storage.set("a", 1)
2626
storage.set("b", 2)

0 commit comments

Comments
 (0)