Skip to content

TypeError: Cannot create a consistent method resolution order (MRO) for bases #2938

@lijok

Description

@lijok

Using Linear's schema (https://studio.apollographql.com/public/Linear-API/variant/current/schema/reference)
schema.json

Command:

datamodel-codegen \
  --input schema.graphql \
  --input-file-type graphql \
  --output models.py \
  --output-model-type pydantic_v2.BaseModel \
  --target-pydantic-version 2.11 \
  --use-annotated \
  --field-constraints \
  --snake-case-field \
  --use-serialization-alias \
  --use-schema-description \
  --graphql-no-typename  \
  --class-name-prefix Linear  \
  --enable-command-header \
  --enable-faux-immutability \
  --enable-version-header \
  --use-generic-base-class \
  --use-double-quotes

Running:

python3.13 models.py

Yields:

Traceback (most recent call last):
  File "/Users/eimantas.gecas/git/hologen-core/infrastructure/hgctl/src/hgctl/types/linear/models.py", line 30252, in <module>
    class LinearCustomerNeedNotification(LinearEntity, LinearNode, LinearNotification):
    ...<183 lines>...
        ]
  File "/Users/eimantas.gecas/git/hologen-core/infrastructure/hgctl/.venv/lib/python3.13/site-packages/pydantic/_internal/_model_construction.py", line 155, in __new__
    cls = cast('type[BaseModel]', super().__new__(mcs, cls_name, bases, namespace, **kwargs))
                                  ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen abc>", line 106, in __new__
TypeError: Cannot create a consistent method resolution order (MRO) for bases LinearEntity, LinearNode, LinearNotification

The problem can be fixed by restructuring the class from:

class LinearCustomerNeedNotification(LinearEntity, LinearNode, LinearNotification)

To:

class LinearCustomerNeedNotification(LinearNotification, LinearEntity, LinearNode)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions