Skip to content

Commit 2941ec1

Browse files
committed
ConsoleProtocol: Update Signatures to match ConsoleExpectMixin
The ConsoleExpectMixin has learned some new tricks over time. But the ConsoleProtocol was not updated accordingly. Every class implementing the ConsoleProtocol also uses the ConsoleExpectMixin - so it's safe to update the signatures according to the ConsoleExpectMixin. For ConsoleProtocol.expect() I've used the type definition of the underlying pexpect library. I have not updated the return types, since it's not clear to me what the ConsoleExpectMixin should return. Signed-off-by: Chris Fiege <cfi@pengutronix.de>
1 parent ef0f630 commit 2941ec1

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

labgrid/protocol/consoleprotocol.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import abc
2+
from typing import Optional, Union
3+
from pexpect import EOF, TIMEOUT
24

35

46
class ConsoleProtocol(abc.ABC):
57
"""Abstract class for the ConsoleProtocol"""
68

79
@abc.abstractmethod
8-
def read(self):
10+
def read(self, size: int = 1, timeout: float = 0.0, max_size: Optional[int] = None):
911
"""
1012
Read data from underlying port
1113
"""
@@ -24,7 +26,16 @@ def sendline(self, line: str):
2426
def sendcontrol(self, char: str):
2527
raise NotImplementedError
2628

27-
def expect(self, pattern: str):
29+
def expect(
30+
self,
31+
pattern: Union[
32+
str, bytes, type[EOF], type[TIMEOUT], list[
33+
Union[str, bytes, type[EOF], type[TIMEOUT]]
34+
]
35+
],
36+
37+
timeout: float = -1,
38+
):
2839
raise NotImplementedError
2940

3041
class Client(abc.ABC):

0 commit comments

Comments
 (0)