On py3.9 and py3.10, dict[str, str] and other typing forms are kinda considered classes, but they still fail when doing issubclass, so specifically exclude generic aliases before calling issubclass.
Fix #4424
Bonus fix: support upcasting of pydantic v1 and v2 models
Adds some test coverage to this sorta dodgy bit of code that has already introduced at least 3 bugs since being added.
On py3.9 and py3.10,
dict[str, str]
and other typing forms are kinda considered classes, but they still fail when doingissubclass
, so specifically exclude generic aliases before calling issubclass.Fix #4424
Bonus fix: support upcasting of pydantic v1 and v2 models
Adds some test coverage to this sorta dodgy bit of code that has already introduced at least 3 bugs since being added.