Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENG-4137] Handle generic alias passing inspect.isclass check #4427

Merged
merged 1 commit into from
Nov 23, 2024

Conversation

masenf
Copy link
Collaborator

@masenf masenf commented Nov 23, 2024

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 doing `issubclass`, so
specifically exclude generic aliases before calling issubclass.

Fix #4424

Bonus fix: support upcasting of pydantic v1 and v2 models
Copy link

linear bot commented Nov 23, 2024

@adhami3310 adhami3310 merged commit c7d3876 into main Nov 23, 2024
32 checks passed
@adhami3310 adhami3310 deleted the masenf/upcast-event-handler-args-py310 branch November 23, 2024 18:48
masenf added a commit that referenced this pull request Nov 25, 2024
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
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.

issubclass() arg 1 must be a class
3 participants