Skip to content

Commit 0aafb5f

Browse files
committed
Comply with unused variable warnings
AI: This commit should have tag name unused-variables and should be force-pushed to a branch of that name as necessary.
1 parent ace2470 commit 0aafb5f

13 files changed

+72
-51
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ reportUnknownMemberType = "none"
6969
reportUnknownVariableType = "none"
7070
reportUnnecessaryTypeIgnoreComment = "none"
7171
enableTypeIgnoreComments = true
72-
failOnWarnings = false # basedpyright setting
7372
include = ["src", "tests"]
7473

7574
[tool.mypy]

tests/handler/test_handler_validates_service_handler_collection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Service:
2424
pass
2525

2626
with pytest.raises(RuntimeError):
27-
Handler([Service()])
27+
_ = Handler([Service()])
2828

2929

3030
def test_services_are_collected():
@@ -77,4 +77,4 @@ class Service2:
7777
pass
7878

7979
with pytest.raises(RuntimeError):
80-
Handler([Service1(), Service2()])
80+
_ = Handler([Service1(), Service2()])

tests/handler/test_invalid_usage.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ class SD:
3939
@service_handler(service=SD)
4040
class SH:
4141
@sync_operation(name="foo")
42-
async def my_op(self, ctx: StartOperationContext, input: None) -> None: ...
42+
async def my_op(
43+
self, _ctx: StartOperationContext, _input: None
44+
) -> None: ...
45+
46+
_ = SH
4347

4448
error_message = "Operation handlers may not override the name of an operation in the service definition"
4549

@@ -56,9 +60,11 @@ class SD:
5660
class SH:
5761
@sync_operation
5862
async def my_op_1(
59-
self, ctx: StartOperationContext, input: None
63+
self, _ctx: StartOperationContext, _input: None
6064
) -> None: ...
6165

66+
_ = SH
67+
6268
error_message = "does not implement an operation with method name 'my_op_2'"
6369

6470

@@ -73,14 +79,16 @@ class SD:
7379
class SH:
7480
@sync_operation
7581
async def my_op_1(
76-
self, ctx: StartOperationContext, input: None
82+
self, _ctx: StartOperationContext, _input: None
7783
) -> None: ...
7884

7985
@sync_operation
8086
async def my_op_2(
81-
self, ctx: StartOperationContext, input: None
87+
self, _ctx: StartOperationContext, _input: None
8288
) -> None: ...
8389

90+
_ = SH
91+
8492
error_message = "does not match an operation method name in the service definition"
8593

8694

@@ -94,7 +102,11 @@ class SD:
94102
@service_handler(service=SD)
95103
class SH:
96104
@sync_operation
97-
async def my_op(self, ctx: StartOperationContext, input: None) -> None: ...
105+
async def my_op(
106+
self, _ctx: StartOperationContext, _input: None
107+
) -> None: ...
108+
109+
_ = SH
98110

99111
error_message = "has 0 type parameters"
100112

@@ -105,9 +117,9 @@ def build():
105117
@service_handler
106118
class SH:
107119
@sync_operation
108-
def my_op(self, ctx: StartOperationContext, input: None) -> None: ...
120+
def my_op(self, _ctx: StartOperationContext, _input: None) -> None: ...
109121

110-
Handler([SH()])
122+
_ = Handler([SH()])
111123

112124
error_message = "you have not supplied an executor"
113125

@@ -130,6 +142,8 @@ class SD:
130142
output_type=None,
131143
)
132144

145+
_ = SD
146+
133147
error_message = "Operation method name 'my_op' is not unique"
134148

135149

@@ -141,6 +155,8 @@ class SubclassingNoInputOutputTypeAnnotationsWithoutServiceDefinition:
141155
@operation_handler
142156
def op(self) -> OperationHandler: ... # type: ignore
143157

158+
_ = SubclassingNoInputOutputTypeAnnotationsWithoutServiceDefinition
159+
144160
error_message = r"has no input type"
145161

146162

tests/handler/test_request_routing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class _TestCase(_BaseTestCase):
3030
class UserServiceHandler:
3131
op: Callable[..., Any] = lambda: None
3232

33-
async def _op_impl(self, ctx: StartOperationContext, input: None) -> bool:
33+
async def _op_impl(self, ctx: StartOperationContext, _input: None) -> bool:
3434
assert (service_defn := get_service_definition(self.__class__))
3535
assert ctx.service == service_defn.name
3636
op_handler_op_defn = get_operation(self.op)

tests/handler/test_service_handler_decorator_requirements.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,5 @@ class HandlerMissingChildOp:
185185
def op_from_base_definition(
186186
self,
187187
) -> OperationHandler[int, str]: ...
188+
189+
_ = HandlerMissingChildOp

tests/handler/test_service_handler_decorator_results_in_correctly_functioning_operation_factories.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class SyncOperation(_TestCase):
7171
class Service:
7272
@sync_operation
7373
async def sync_operation_handler(
74-
self, ctx: StartOperationContext, input: int
74+
self, _ctx: StartOperationContext, _input: int
7575
) -> int:
7676
return 7
7777

tests/handler/test_service_handler_decorator_selects_correct_service_name.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def test_service_decorator_name_overrides(test_case: type[_NameOverrideTestCase]
8787

8888
def test_name_must_not_be_empty():
8989
with pytest.raises(ValueError):
90-
service_handler(name="")(object)
90+
_ = service_handler(name="")(object)
9191

9292

9393
def test_name_and_interface_are_mutually_exclusive():

tests/handler/test_service_handler_decorator_validates_against_service_contract.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def unrelated_method(self) -> None: ...
3131

3232
class Impl:
3333
@sync_operation
34-
async def op(self, ctx: StartOperationContext, input: None) -> None: ...
34+
async def op(self, _ctx: StartOperationContext, _input: None) -> None: ...
3535

3636
error_message = None
3737

@@ -43,7 +43,7 @@ class Interface:
4343

4444
class Impl:
4545
@sync_operation
46-
async def extra_op(self, ctx: StartOperationContext, input: None) -> None: ...
46+
async def extra_op(self, _ctx: StartOperationContext, _input: None) -> None: ...
4747

4848
def unrelated_method(self) -> None: ...
4949

@@ -104,7 +104,7 @@ class Interface:
104104

105105
class Impl:
106106
@sync_operation
107-
async def op(self, ctx: StartOperationContext, input: None) -> str: ...
107+
async def op(self, _ctx: StartOperationContext, _input: None) -> str: ...
108108

109109
error_message = "is not compatible with the output type"
110110

@@ -116,7 +116,7 @@ class Interface:
116116

117117
class Impl:
118118
@sync_operation
119-
async def op(self, ctx: StartOperationContext, input: str) -> str: ...
119+
async def op(self, _ctx: StartOperationContext, _input: str) -> str: ...
120120

121121
error_message = "is not compatible with the output type"
122122

@@ -128,7 +128,7 @@ class Interface:
128128

129129
class Impl:
130130
@sync_operation
131-
async def op(self, ctx: StartOperationContext, input: str) -> None: ...
131+
async def op(self, _ctx: StartOperationContext, _input: str) -> None: ...
132132

133133
error_message = None
134134

@@ -140,7 +140,7 @@ class Interface:
140140

141141
class Impl:
142142
@sync_operation
143-
async def op(self, ctx: StartOperationContext, input: str) -> str: ...
143+
async def op(self, _ctx: StartOperationContext, _input: str) -> str: ...
144144

145145
error_message = None
146146

@@ -164,7 +164,7 @@ class Interface:
164164

165165
class Impl:
166166
@sync_operation
167-
async def op(self, ctx: StartOperationContext, input: X) -> X: ...
167+
async def op(self, _ctx: StartOperationContext, _input: X) -> X: ...
168168

169169
error_message = None
170170

@@ -176,7 +176,7 @@ class Interface:
176176

177177
class Impl:
178178
@sync_operation
179-
async def op(self, ctx: StartOperationContext, input: X) -> Subclass: ...
179+
async def op(self, _ctx: StartOperationContext, _input: X) -> Subclass: ...
180180

181181
error_message = None
182182

@@ -190,7 +190,7 @@ class Interface:
190190

191191
class Impl:
192192
@sync_operation
193-
async def op(self, ctx: StartOperationContext, input: X) -> SuperClass: ...
193+
async def op(self, _ctx: StartOperationContext, _input: X) -> SuperClass: ...
194194

195195
error_message = "is not compatible with the output type"
196196

@@ -202,7 +202,7 @@ class Interface:
202202

203203
class Impl:
204204
@sync_operation
205-
async def op(self, ctx: StartOperationContext, input: X) -> X: ...
205+
async def op(self, _ctx: StartOperationContext, _input: X) -> X: ...
206206

207207
error_message = None
208208

@@ -214,7 +214,7 @@ class Interface:
214214

215215
class Impl:
216216
@sync_operation
217-
async def op(self, ctx: StartOperationContext, input: SuperClass) -> X: ...
217+
async def op(self, _ctx: StartOperationContext, _input: SuperClass) -> X: ...
218218

219219
error_message = None
220220

@@ -226,7 +226,7 @@ class Interface:
226226

227227
class Impl:
228228
@sync_operation
229-
async def op(self, ctx: StartOperationContext, input: Subclass) -> X: ...
229+
async def op(self, _ctx: StartOperationContext, _input: Subclass) -> X: ...
230230

231231
error_message = "is not compatible with the input type"
232232

@@ -272,11 +272,11 @@ class Contract:
272272
class Service:
273273
@sync_operation
274274
async def operation_b(
275-
self, ctx: StartOperationContext, input: None
275+
self, _ctx: StartOperationContext, _input: None
276276
) -> None: ...
277277

278278
with pytest.raises(
279279
TypeError,
280280
match="does not match an operation method name in the service definition",
281281
):
282-
service_handler(service=Contract)(Service)
282+
_ = service_handler(service=Contract)(Service)

tests/handler/test_sync_operation_handler_decorator_creates_valid_operation_handler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ def __init__(self):
1717
self.mutable_container = []
1818

1919
@sync_operation
20-
def my_def_op(self, ctx: StartOperationContext, input: int) -> int:
20+
def my_def_op(self, _ctx: StartOperationContext, input: int) -> int:
2121
"""
2222
This is the docstring for the `my_def_op` sync operation.
2323
"""
2424
self.mutable_container.append(input)
2525
return input + 1
2626

2727
@sync_operation(name="foo")
28-
async def my_async_def_op(self, ctx: StartOperationContext, input: int) -> int:
28+
async def my_async_def_op(self, _ctx: StartOperationContext, input: int) -> int:
2929
"""
3030
This is the docstring for the `my_async_def_op` sync operation.
3131
"""

tests/helpers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
class DummySerializer:
99
value: Any
1010

11-
async def serialize(self, value: Any) -> Content:
11+
async def serialize(self, value: Any) -> Content: # pyright: ignore[reportUnusedParameter]
1212
raise NotImplementedError
1313

1414
async def deserialize(
15-
self, content: Content, as_type: Optional[type[Any]] = None
15+
self,
16+
content: Content, # pyright: ignore[reportUnusedParameter]
17+
as_type: Optional[type[Any]] = None, # pyright: ignore[reportUnusedParameter]
1618
) -> Any:
1719
return self.value

0 commit comments

Comments
 (0)