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

create_model not support generics model #3945

Closed
3 tasks done
hot123s opened this issue Mar 28, 2022 · 0 comments · Fixed by #3946
Closed
3 tasks done

create_model not support generics model #3945

hot123s opened this issue Mar 28, 2022 · 0 comments · Fixed by #3946
Labels
bug V1 Bug related to Pydantic V1.X

Comments

@hot123s
Copy link
Contributor

hot123s commented Mar 28, 2022

Checks

  • I added a descriptive title to this issue
  • I have searched (google, github) for similar issues and couldn't find anything
  • I have read and followed the docs and still think this is a bug

Bug

from typing import Generic, TypeVar

from pydantic import Field, create_model
from pydantic.generics import GenericModel

T = TypeVar("T")


class TestGenericModel(GenericModel):
    pass


AAModel = create_model("AAModel", __base__=(TestGenericModel, Generic[T]), aa=(int, Field(0)))

AAModel[int](aa=1)

output

Traceback (most recent call last):
  File "test.py", line 13, in <module>
    AAModel = create_model("AAModel", __base__=(TestGenericModel, Generic[T]), aa=(int, Field(0)))
  File "pydantic/main.py", line 972, in pydantic.main.create_model
TypeError: type() doesn't support MRO entry resolution; use types.new_class()
@hot123s hot123s added the bug V1 Bug related to Pydantic V1.X label Mar 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug V1 Bug related to Pydantic V1.X
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant