pydantic / pydantic-extra-types

Extra Pydantic types.
MIT License
181 stars 48 forks source link

Support for rrule #118

Open avivgood opened 8 months ago

avivgood commented 8 months ago

Hi, so I had a use case where I needed to represent an event that reoccurred every X time for the duration of Y time, and I wanted to represent this event in my FastAPI + Pydantic stack. [https://stackoverflow.com/questions/77705081/time-intervals-in-python](This is the full use case). I concluded that implementing this on my own would require a lot of validation and parsing. I found out there is already a standard for it : RFC 5545 - ICalender, which as far as I know, the rrule part of it is implemented in [https://dateutil.readthedocs.io/en/stable/rrule.html](dateuttil package) However, while it is supported in many JS calendars, I couldn't find support for it, especially for rrule, as a "first citizen" Pydantic type. I will admit I am not very knowledgeable about how Pydantic is implemented, however, an rrule can't generate a pydantic-core schema (i.e the error: pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for <module 'dateutil.rrule' from '<...>/dateutil/rrule.py'>. Setarbitrary_types_allowed=Truein the model_config to ignore this error or implement__get_pydantic_core_schema__on your type to fully support it. And therefore I can't use it in my swagger and API. I know the dateutil package it third-party, and most of the types supported by Pydantic are not, however, since this is the calendering standard, I do think Pydantic support would be helpful here.

Original issue: https://github.com/pydantic/pydantic/issues/8451