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: Typo in field_meta.py ? #443

Open
4 tasks
Leobouloc opened this issue Nov 27, 2023 · 3 comments
Open
4 tasks

Bug: Typo in field_meta.py ? #443

Leobouloc opened this issue Nov 27, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@Leobouloc
Copy link

Leobouloc commented Nov 27, 2023

Description

By analogy, I assume the line:

"max_length": getattr(value, "max_length", getattr(value, "max_length", None)),

should be:

"max_length": getattr(value, "max_length", getattr(value, "max_items", None)),

(if it is not a typo, the second getattr is redundant and could be removed)

"max_length": getattr(value, "max_length", getattr(value, "max_length", None)),
"min_length": getattr(value, "min_length", getattr(value, "min_items", None)),

URL to code causing the issue

"max_length": getattr(value, "max_length", getattr(value, "max_length", None)),

MCVE

No response

Steps to reproduce

No response

Screenshots

No response

Logs

No response

Release Version

2.12.0

Platform

  • Linux
  • Mac
  • Windows
  • Other (Please specify in the description above)

Note

While we are open for sponsoring on GitHub Sponsors and
OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.

Check out all issues funded or available for funding on our Polar.sh Litestar dashboard

  • If you would like to see an issue prioritized, make a pledge towards it!
  • We receive the pledge once the issue is completed & verified
  • This, along with engagement in the community, helps us know which features are a priority to our users.
Fund with Polar
@Leobouloc Leobouloc added the bug Something isn't working label Nov 27, 2023
@guacs
Copy link
Member

guacs commented Nov 27, 2023

@Leobouloc thanks! It's both a bug and not a bug at the same time 😄 This was included to handle parsing of constraints for pydantic v1, but the logic for v1 of pydantic doesn't use the FieldMeta.parse_constraints method due to it needing some specialized logic in how they're handled. Hence, no one's had any validation issues so far.

If you're willing, feel free to raise a PR to fix it :)

@Leobouloc
Copy link
Author

Hi, Thanks for your answer. I would be glad to contribute, but am afraid I don't really understand the inner workings of the package ?

Concerning your answer, are you saying that max_length should be max_items or are you suggesting larger changes ?

@guacs
Copy link
Member

guacs commented Nov 28, 2023

I would be glad to contribute, but am afraid I don't really understand the inner workings of the package ?

That's completely fine! You can still give it a go and if you need any help, feel free to ask here or in discord.

Concerning your answer, are you saying that max_length should be max_items or are you suggesting larger changes ?

I think we can just remove that check for max_items and min_items from there. It's only for v1 and since we're not using parse_constraints for v1, there's no reason to keep them there.

EDIT: Also, there are larger changes with respect to how v1 is handled that are planned which is being tracked in #435. I haven't been able to really get it to work yet because of how the API of pydantic v1 works.

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

No branches or pull requests

2 participants