Skip to content

Commit c94eb6c

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.
1 parent 0ba0f75 commit c94eb6c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

labgrid/protocol/consoleprotocol.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import abc
2+
from typing import Optional
3+
4+
from pexpext import EOF, TIMEOUT
25

36

47
class ConsoleProtocol(abc.ABC):
58
"""Abstract class for the ConsoleProtocol"""
69

710
@abc.abstractmethod
8-
def read(self):
11+
def read(self, size: int = 1, timeout: float = 0.0, max_size: Optional[int] = None):
912
"""
1013
Read data from underlying port
1114
"""
@@ -24,7 +27,11 @@ def sendline(self, line: str):
2427
def sendcontrol(self, char: str):
2528
raise NotImplementedError
2629

27-
def expect(self, pattern: str):
30+
def expect(
31+
self,
32+
pattern: str | bytes | type[EOF] | type[TIMEOUT] | list[str | bytes | type[EOF] | type[TIMEOUT]],
33+
timeout: float = -1,
34+
):
2835
raise NotImplementedError
2936

3037
class Client(abc.ABC):

0 commit comments

Comments
 (0)