Skip to content

Commit 090a9f9

Browse files
committed
typing: add minimal types for mypy to not show error
1 parent db829a8 commit 090a9f9

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

varlink/server.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from socketserver import ForkingMixIn
1414

1515
from types import GeneratorType
16+
from typing import Optional
1617

1718

1819
class Service:
@@ -324,7 +325,7 @@ class RequestHandler(StreamRequestHandler):
324325
Instantiate your own class and set the class variable service to your global :class:`Service` object.
325326
"""
326327

327-
service = None
328+
service: Optional[Service] = None
328329

329330
def handle(self):
330331
message = b""

varlink/tests/test_certification.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def __init__(self, wants, got):
8888

8989
@service.interface("org.varlink.certification")
9090
class CertService:
91-
next_method = {}
91+
next_method: dict[str, str] = {}
9292

9393
def new_client_id(self, _server):
9494
client_id = codecs.getencoder("hex")(os.urandom(16))[0].decode("ascii")
@@ -477,6 +477,8 @@ def usage():
477477
with varlink.Client.new_with_activate([__file__, "--varlink=$VARLINK_ADDRESS"]) as client:
478478
run_client(client)
479479
elif client_mode:
480+
if client is None:
481+
raise ValueError("--client requires at either of --varlink, --bridge or --activate")
480482
with client:
481483
run_client(client)
482484
else:

varlink/tests/test_mocks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
class Service:
15-
def Test1(self, param1: int) -> str:
15+
def Test1(self, param1: int) -> dict[str, dict[str, str]]:
1616
"""return test: MyPersonalType"""
1717
return {
1818
"test": {
@@ -24,7 +24,7 @@ def Test1(self, param1: int) -> str:
2424
def Test2(self, param1: str = "test") -> None:
2525
pass
2626

27-
def Test3(self, param1: str) -> str:
27+
def Test3(self, param1: str) -> dict[str, str]:
2828
"""return test"""
2929
return {"test": param1}
3030

varlink/tests/test_orgexamplemore.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ def epilog():
200200
with varlink.Client.new_with_activate([__file__, "--varlink=$VARLINK_ADDRESS"]) as client:
201201
run_client(client)
202202
elif client_mode:
203+
if client is None:
204+
raise ValueError("--client requires at either of --varlink, --bridge or --activate")
203205
with client:
204206
run_client(client)
205207
else:

0 commit comments

Comments
 (0)