Skip to content

Commit

Permalink
Perform strict mypy typing check (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
cottsay authored Dec 14, 2023
1 parent 04f16c8 commit ba43a23
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: python -m pip install -U mypy
- run: python -m mypy -p aioraven
- run: python -m mypy -p aioraven --strict
pydocstyle:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion aioraven/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def convert_datetime(
raw: Optional[str],
utc: bool = False
) -> Optional[datetime]:
if raw is not None and raw != 0xffffff:
if raw is not None and raw != '0xffffff':
value = datetime(
2000, 1, 1, 0, 0,
tzinfo=timezone.utc if utc else None)
Expand Down
2 changes: 1 addition & 1 deletion aioraven/serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import Tuple

from aioraven.protocols import RAVEnReaderProtocol
from aioraven.streams import RAVEnReader
from aioraven.reader import RAVEnReader
from aioraven.streams import RAVEnStreamDevice
from aioraven.streams import RAVEnWriter
from serial_asyncio import create_serial_connection
Expand Down
14 changes: 11 additions & 3 deletions aioraven/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ async def open_connection(
return reader, writer


class RAVEnStreamDevice(RAVEnBaseDevice, AbstractAsyncContextManager):
class RAVEnStreamDevice(
RAVEnBaseDevice,
AbstractAsyncContextManager['RAVEnStreamDevice']
):
"""Read and write coordination for stream-based RAVEn devices."""

_reader: Optional[RAVEnReader] = None
Expand Down Expand Up @@ -138,11 +141,16 @@ async def _query(
self._writer.write_cmd(cmd_name, args)
return await waiter if waiter is not None else None

async def __aenter__(self):
async def __aenter__(self) -> 'RAVEnStreamDevice':
await self.open()
return self

async def __aexit__(self, exc_type, exc_value, traceback):
async def __aexit__(
self,
exc_type: Any,
exc_value: Any,
traceback: Any
) -> None:
await self.close()


Expand Down

0 comments on commit ba43a23

Please sign in to comment.