Skip to content
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

Python internal types are not supported #25

Open
NN--- opened this issue Mar 6, 2024 · 3 comments
Open

Python internal types are not supported #25

NN--- opened this issue Mar 6, 2024 · 3 comments

Comments

@NN---
Copy link

NN--- commented Mar 6, 2024

Add support to list in addition to List
See: https://peps.python.org/pep-0585/

@robabram
Copy link
Owner

robabram commented Jul 14, 2024

This library does support using standard Python collections as type annotations, I have added a unittest to show this.

test_pep585_collection_types

Do you have an example of an error you are seeing?

@NN---
Copy link
Author

NN--- commented Sep 4, 2024

class RR(JSONObject):
    values: Optional[list[int]] # here list is okay

class P(JSONObject):
    R: List[RR] # here list cannot be used

class Q(JSONObject):
    W: List[P] # and here too

class P2(JSONObject):
    R: List[RR] # here list cannot be used

class Q2(JSONObject):
    W: List[P] # and here too

# OK
x = Q(json.loads('{ "W": [ { "R": [ { "values": [ 1 ,2 , 3] } ] } ] }'))

# list() takes no keyword arguments
x2 = Q2(json.loads('{ "W": [ { "R": [ { "values": [ 1 ,2 , 3] } ] } ] }'))

@NN---
Copy link
Author

NN--- commented Sep 4, 2024

comparison_methods\python_easy_object.py", line 211, in __init__
    _tmp.append(t(i, cast_types=cast_types, ordered=ordered))
                ~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: list() takes no keyword arguments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants