python-trio / trio-typing

Type hints for Trio and related projects
Other
27 stars 16 forks source link

`mypy` reports memory channel attributes as missing? #48

Closed goodboy closed 2 years ago

goodboy commented 2 years ago

Not sure if I just never called these methods before or what (as in I was always using the async versions?) but recent mypy is reporting the following for me in this tractor dev branch actions run:

Run mypy tractor/ --ignore-missing-imports
  mypy tractor/ --ignore-missing-imports
  shell: /usr/bin/bash -e {0}
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.9.9/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.9/x64/lib
tractor/to_asyncio.py:165: error: "MemorySendChannel[Any]" has no attribute "close"; maybe "aclose" or "clone"?
tractor/to_asyncio.py:209: error: "MemoryReceiveChannel[Any]" has no attribute "close"; maybe "aclose" or "clone"?
tractor/to_asyncio.py:295: error: "MemoryReceiveChannel[Any]" has no attribute "__enter__"
tractor/to_asyncio.py:295: error: "MemoryReceiveChannel[Any]" has no attribute "__exit__"
Found 4 errors in 1 file (checked 25 source files)

This seems pretty odd to me given the trio channel types definitely define these methods.

goodboy commented 2 years ago

Huh, yeah as a follow up, doesn't seem like we ever have called MemoryReceiveChannel.close() in the code base before?

oremanj commented 2 years ago

This was fixed in https://github.com/python-trio/trio-typing/commit/994e434294ae51f0495dbb4fbd733a57c4ae5ed4 but there hasn't been a release since then. I'm planning to roll one tonight.