According to the documentation, "pydantic may cast input data to force it to conform to model field types [...] This is a deliberate decision of pydantic, and in general it's the most useful approach."
The following code works as expected:
>>> from pydantic import BaseModel
>>> class Foo(BaseModel):
... bar: int
>>> foo = Foo(bar="3") # Passing a string
And mypy doesn't complain, but PyCharm's PyTypeChecker does:
Expected type 'int', got 'str' instead
Is there any way I can keep using automatic data conversion and avoid the inspection error (other than disabling the inspection)?
Using Python 3.8.10, Pydantic 1.8.2, Mypy 0.910, PyCharm 2021.2.2 2021.2.3