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

Strict mode rejects valid types #8604

Closed
Dreamsorcerer opened this issue Jan 22, 2024 · 4 comments · Fixed by #8614
Closed

Strict mode rejects valid types #8604

Dreamsorcerer opened this issue Jan 22, 2024 · 4 comments · Fixed by #8614
Labels
bug V2 Bug related to Pydantic V2

Comments

@Dreamsorcerer
Copy link

Dreamsorcerer commented Jan 22, 2024

Description

In this example, it requires a list even though I didn't ask for a list.

Example Code

>>> TypeAdapter(Sequence[int]).validate_python((), strict=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pydantic/type_adapter.py", line 239, in validate_python
    return self.validator.validate_python(__object, strict=strict, from_attributes=from_attributes, context=context)
pydantic_core._pydantic_core.ValidationError: 1 validation error for json-or-python[json=list[int],python=chain[is-instance[Sequence],function-wrap[sequence_validator()]]]
  Input should be a valid list [type=list_type, input_value=(), input_type=tuple]
    For further information visit https://errors.pydantic.dev/2.5/v/list_type
@Dreamsorcerer Dreamsorcerer added bug V2 Bug related to Pydantic V2 pending Awaiting a response / confirmation labels Jan 22, 2024
@sydney-runkle sydney-runkle removed the pending Awaiting a response / confirmation label Jan 23, 2024
@sydney-runkle
Copy link
Member

@Dreamsorcerer,

Thanks for reporting this! This does look like a bug. What version of pydantic are you using?

@Dreamsorcerer
Copy link
Author

I tested a couple of versions, it's still present on latest version.

@sydney-runkle
Copy link
Member

@Dreamsorcerer,

I've opened a PR with a potential fix, we'll get a fix for this into 2.7!

@sydney-runkle
Copy link
Member

@Dreamsorcerer,

Merged the PR :) should be fixed on main now.

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

Successfully merging a pull request may close this issue.

2 participants