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
Not being able to type recursive types seems like a big regression? I thought this used to be possible in pyre. I stumbled upon this today at work and I'm surprised not more people are asking for this.
Pyre Bug
Bug description
This recursive type alias for JSON data does not work in pyre:
Output:
Reproduction steps
https://pyre-check.org/play?input=%23%20pyre-strict%0Afrom%20typing%20import%20TypeAlias%0A%0AJSON%3A%20TypeAlias%20%3D%20None%20%7C%20bool%20%7C%20int%20%7C%20float%20%7C%20str%20%7C%20list%5B%22JSON%22%5D%20%7C%20dict%5Bstr%2C%20%22JSON%22%5D
Alternatively:
Expected behavior
No errors
Logs
Please run your reproduction steps followed by
pyre rage > pyre_rage.log
, and upload the file here:pyre_rage.log
Additional context
This is the recommended definition from python/typing#182 (comment)
The code type-checks in mypy and pytype.
Omitting the quotes makes the code pass in pyre, but results in NameError at runtime:
This NameError cannot be avoided with future annotations, because it doesn't occur in an annotation.
PEP 695 type aliases don't appear to be supported yet:
Omitting the
TypeAlias
annotation avoids the first of the errors, but not the remaining four (missing argument, incompatible parameter type).The text was updated successfully, but these errors were encountered: