Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sensor_reading and sensor_value helpers #86

Merged
merged 5 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/aiokatcp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ class _Handler(Protocol):

class _InformHandler(_Handler):
def __call__(self, _client: "Client", _msg: core.Message) -> None:
...
... # pragma: nocover


class _InformCallback(_Handler):
def __call__(self, _msg: core.Message) -> None:
...
... # pragma: nocover


class _PendingRequest:
Expand Down Expand Up @@ -224,7 +224,7 @@ async def handle_message(self, conn: connection.Connection, msg: core.Message) -
elif msg.mtype == core.Message.Type.INFORM:
req.informs.append(msg)
else:
self.logger.warning("Unknown message type %s", msg.mtype) # pragma: no cover
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean this one looks as though we can probably explicitly test for it but it would be a bit contrived.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure it's possible, but also outside the scope of this PR.

self.logger.warning("Unknown message type %s", msg.mtype) # pragma: nocover
elif msg.mtype == core.Message.Type.INFORM:
self.handle_inform(msg)
else:
Expand Down Expand Up @@ -620,11 +620,11 @@ async def request(self, name: str, *args: Any) -> Tuple[List[bytes], List[core.M

@overload
async def sensor_reading(self, sensor_name: str, sensor_type: None = None) -> sensor.Reading:
...
... # pragma: nocover

@overload
async def sensor_reading(self, sensor_name: str, sensor_type: Type[_T]) -> sensor.Reading[_T]:
...
... # pragma: nocover

async def sensor_reading(
self, sensor_name: str, sensor_type: Optional[type] = None
Expand Down Expand Up @@ -678,11 +678,11 @@ async def sensor_reading(

@overload
async def sensor_value(self, sensor_name: str, sensor_type: None = None) -> Any:
...
... # pragma: nocover

@overload
async def sensor_value(self, sensor_name: str, sensor_type: Type[_T]) -> _T:
...
... # pragma: nocover

async def sensor_value(self, sensor_name: str, sensor_type: Optional[type] = None) -> Any:
"""Request the value of a single sensor from the server.
Expand Down
2 changes: 1 addition & 1 deletion src/aiokatcp/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ def close(self) -> None:

@abc.abstractmethod
def _parameters(self) -> tuple:
pass # pragma: no cover
pass # pragma: nocover

def parameters(self) -> tuple:
"""Return the parameters with which the sensor was created."""
Expand Down
Loading