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

[Bug] JSON validation with dataclass model does not works with list #4

Closed
leotada opened this issue Oct 14, 2021 · 0 comments · Fixed by #47
Closed

[Bug] JSON validation with dataclass model does not works with list #4

leotada opened this issue Oct 14, 2021 · 0 comments · Fixed by #47
Labels
bug Something isn't working

Comments

@leotada
Copy link

leotada commented Oct 14, 2021

Describe the bug
I tried to use the sanic-ext validation to validate a complex json body without pydantic, and occour error. Using the pydantic model works.

To Reproduce
Validate like this example of models, using built-in list keyword:

@dataclass
class User:
    id: int
    name: str
    friends: list[Friend]

@dataclass
class Friend:
    name: str

Expected behavior
Validate normally.

Environment (please complete the following information):

  • OS: Endeavour OS Linux

Additional context
Like @ahopkins said, maybe this is a bug related to 'list' keyword that is builtin in more recent Python versions. Using the List type imported of typing module appears to work as expected.
https://discord.com/channels/812221182594121728/872787982741032971/898279553288523807

@ChihweiLHBird ChihweiLHBird added the bug Something isn't working label Jan 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants