79473532

Date: 2025-02-27 17:58:48
Score: 1.5
Natty:
Report link

According to https://github.com/microsoft/pyright/issues/3678 there is no way to indicate to Pylance that both strings and datetimes are accepted. But this can be done with mypy and pydantic's mypy plugin https://docs.pydantic.dev/latest/integrations/mypy/

Don't add str to annotations. It will change schema and validation of the fields.

With other type checkers you need to decide what is more important for you: convenience of pydantic type coercion or accuracy of types. You can silence type checking errors or convert types yourself before pydantic.

Reasons:
  • No code block (0.5):
  • Low reputation (1):
Posted by: Nine Treasures