aioserial.py icon indicating copy to clipboard operation
aioserial.py copied to clipboard

Example in README.MD does not work

Open schperplata opened this issue 9 months ago • 0 comments

Example in README, aioserial equivalence chapter, does not work.

Here is the traceback:

...test_aiserial.py:16: DeprecationWarning: There is no current event loop
  asyncio.run(asyncio.gather(read_and_print(aioserial_instance), aioserial_instance.write_async(b"Hello, World!\n")))
Traceback (most recent call last):
  File "...test_aiserial.py", line 16, in <module>
    asyncio.run(asyncio.gather(read_and_print(aioserial_instance), aioserial_instance.write_async(b"Hello, World!\n")))
  File "Python311\Lib\asyncio\runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "Python311\Lib\asyncio\runners.py", line 89, in run
    raise ValueError("a coroutine was expected, got {!r}".format(coro))
ValueError: a coroutine was expected, got <_GatheringFuture pending>
sys:1: RuntimeWarning: coroutine 'AioSerial.write_async' was never awaited
sys:1: RuntimeWarning: coroutine 'read_and_print' was never awaited

VSCode Pylance static analysis reports:

Argument of type "Future[tuple[None, int]]" cannot be assigned to parameter "main" of type "Coroutine[Any, Any, _T@run]" in function "run"
  "Future[tuple[None, int]]" is incompatible with "Coroutine[Any, Any, _T@run]"Pylance[reportGeneralTypeIssues](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportGeneralTypeIssues)

Windows 10, 64 bit Python 3.11.0 aioserial==1.3.1 pyserial==3.5

schperplata avatar Sep 03 '23 09:09 schperplata