This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Ricyteach
Recipients Ricyteach, eric.smith
Date 2018-03-30.18:03:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1522433023.64.0.467229070634.issue33188@psf.upfronthosting.co.za>
In-reply-to
Content
I'm getting the following error at when attempting to create a new `dataclass` with any base class that is supplied a type variable:

    TypeError: type() doesn't support MRO entry resolution; use types.new_class()

In principle, it seems like this shouldn't cause any problems, since this works as expected:

    @dataclass
    class MyClass(Generic[MyTypeVar]):
        pass

The problem seems to be the call to `type` in `make_dataclass` for instantiating the class object, since `type` doesn't support type variables. If I replace the `dataclass` line that produces the error with the following code block, it seems to work:

    try:
        cls = type(cls_name, bases, namespace)
    except TypeError:
        cls = types.new_class(cls_name, bases, namespace)

I haven't tested, but it might be possible to just remove the call to `type` altogether.

I've attached a file demonstrating the issue.
History
Date User Action Args
2018-03-30 18:03:43Ricyteachsetrecipients: + Ricyteach, eric.smith
2018-03-30 18:03:43Ricyteachsetmessageid: <1522433023.64.0.467229070634.issue33188@psf.upfronthosting.co.za>
2018-03-30 18:03:43Ricyteachlinkissue33188 messages
2018-03-30 18:03:43Ricyteachcreate