Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

edmundhighcock
Copy link

@edmundhighcock edmundhighcock commented Feb 17, 2024

Support the special type hints that pydantic provides to give more control over validating dates.

Enable Pydantic custom datetime type hints

Pydantic has some additional classes that you can use as type hints to give more control over validating dates.

https://docs.pydantic.dev/2.0/usage/types/datetime/#pydantic-date-types

edmundhighcock and others added 2 commits February 17, 2024 23:03
Support the special type hints that pydantic provides to give more control over validating dates.
@dantheman39
Copy link
Contributor

dantheman39 commented Feb 19, 2024

Thanks for this @edmundhighcock !

Could you please add some unit test coverage? This might be a good place to look:

@pytest.mark.parametrize(
"input, expected",
[
((bool, False), graphene.Boolean),
((float, 0.1), graphene.Float),
((int, 6), graphene.Int),
((str, "hi"), graphene.String),
((uuid.UUID, uuid.uuid4()), graphene.UUID),
((datetime.date, datetime.date(2019, 1, 1)), graphene.Date),
((datetime.time, datetime.time(15, 29)), graphene.Time),
((datetime.datetime, datetime.datetime(2019, 1, 1, 1, 37)), graphene.DateTime),
],
)
def test_builtin_scalars(input, expected):

@edmundhighcock
Copy link
Author

Thanks for this @edmundhighcock !

Could you please add some unit test coverage? This might be a good place to look:

@pytest.mark.parametrize(
"input, expected",
[
((bool, False), graphene.Boolean),
((float, 0.1), graphene.Float),
((int, 6), graphene.Int),
((str, "hi"), graphene.String),
((uuid.UUID, uuid.uuid4()), graphene.UUID),
((datetime.date, datetime.date(2019, 1, 1)), graphene.Date),
((datetime.time, datetime.time(15, 29)), graphene.Time),
((datetime.datetime, datetime.datetime(2019, 1, 1, 1, 37)), graphene.DateTime),
],
)
def test_builtin_scalars(input, expected):

Sorry for the slow reply. Yes, will happily do this as soon as I have time.

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

Successfully merging this pull request may close these issues.

2 participants