You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I'm seeing inconsistent behavior between defining a generic class and importing it. (Or well, someone else did, I'm just pretty sure what's happening is a pyright bug. python-trio/trio#2873)
Code or Screenshots
Unfortunately the first few attempts I did to try to spit out something that I thought was the cause (inheriting from Tuple, implied generics) didn't yield this same error. So, here's something that depends on trio==0.23.1:
C:\Users\A5rocks\Documents\trio\empty\pyright-repro.py
C:\Users\A5rocks\Documents\trio\empty\pyright-repro.py:16:13 - information: Type of "omc" is "type[omc[Unknown]]"
C:\Users\A5rocks\Documents\trio\empty\pyright-repro.py:17:13 - information: Type of "open_memory_channel" is "type[open_memory_channel]"
0 errors, 0 warnings, 2 informations
... Which seems wrong given omc is literally copy-pasted from open_memory_channel's definition, with Tuple -> typing.Tuple and replacing the body of __new__ with ....
VS Code extension or command-line
Installed via pip and pip show pyright reports version 1.1.334.
The text was updated successfully, but these errors were encountered:
Pyright is working correctly here, so I don't consider this a bug.
The problem is in the trio/_channel.py file. It declares a class called open_memory_channel. It derives from the type Tuple[MemorySendChannel[T], MemoryReceiveChannel[T]]. The problem is that MemorySendChannel and MemoryReceiveChannel are not defined at that point in the file, so they are evaluated as Unknown. The resulting class is therefore not considered generic. If you move the declaration of the open_memory_channel class later in the file (after MemorySendChannel and MemoryReceiveChannel have been defined, then it will work as you expect.
Describe the bug
I'm seeing inconsistent behavior between defining a generic class and importing it. (Or well, someone else did, I'm just pretty sure what's happening is a pyright bug. python-trio/trio#2873)
Code or Screenshots
Unfortunately the first few attempts I did to try to spit out something that I thought was the cause (inheriting from
Tuple
, implied generics) didn't yield this same error. So, here's something that depends ontrio==0.23.1
:Pyright, in response spits out:
... Which seems wrong given
omc
is literally copy-pasted fromopen_memory_channel
's definition, withTuple
->typing.Tuple
and replacing the body of__new__
with...
.VS Code extension or command-line
Installed via
pip
andpip show pyright
reports version 1.1.334.The text was updated successfully, but these errors were encountered: