-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type checking tuple type for fields causes infinite recursion #291
Comments
So I found that the problem is that the type checking is simply not complete, and I think if you want complete type checking in pyrsistent, then you should probably use some other type checking library, as python's builtin type checking seems inadequate for this. For example, even if you add separate instance checks for
So you have to create a bunch of cases to handle all of these type-like objects which are not actually However, I think the solution should be to allow types to be specified how the user wants, with the declarations that python already allows (like using a union If for some reason the type checking must remain, then I think it should be able to be disabled by the user (because it's incomplete and produces errors like above). |
Similar type checking woes mentioned here: #181 |
Seems like I can bypass the library's type checking by putting my type right on the variable instead, so that solves my particular issue. from pyrsistent import *
tuple_type = tuple[int, int]
class Test(PClass):
x:tuple_type = field() |
Specifying a tuple type for a field seems to break pyrsistent's type checker.
Pyrsistent version 0.20.0
Python 3.12
Linux (NixOS)
Minimal example
test.py
:Load the module:
Output:
The text was updated successfully, but these errors were encountered: