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

craft-grammar does not coerce numbers to strings in annotated types #49

Closed
mr-cal opened this issue Sep 16, 2024 · 1 comment · Fixed by #50
Closed

craft-grammar does not coerce numbers to strings in annotated types #49

mr-cal opened this issue Sep 16, 2024 · 1 comment · Fixed by #50
Assignees
Labels
bug Something isn't working triaged

Comments

@mr-cal
Copy link
Contributor

mr-cal commented Sep 16, 2024

Pydantic 2 requires coerce_numbers_to_str = True to be set, but this does not work for annotated types, such as craft-application's SingleEntryDict:

SingleEntryDict = Annotated[
    dict[T, Tv],
    pydantic.Field(min_length=1, max_length=1),
]

Parsing the following with craft-grammar

build-environment:
  - CGO_ENABLED: 0

produces

 >       v = ValidationTest(**data)
  E       pydantic_core._pydantic_core.ValidationError: 1 validation error for ValidationTest
  E       build_environment
  E         Value error, value must be a list of Annotated: [{'CGO_ENABLED': 0}] [type=value_error, input_value=[{'CGO_ENABLED': 0}], input_type=list]
  E           For further information visit https://errors.pydantic.dev/2.9/v/value_error

See full logs in this PR: #46

@mr-cal mr-cal added the triaged label Sep 16, 2024
Copy link

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-3389.

This message was autogenerated

@lengau lengau self-assigned this Sep 16, 2024
@lengau lengau added the bug Something isn't working label Sep 16, 2024
@lengau lengau linked a pull request Sep 19, 2024 that will close this issue
3 tasks
@lengau lengau closed this as completed Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants