-
Notifications
You must be signed in to change notification settings - Fork 16
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
TypeError: metaclass conflict with Django #12
Comments
What One of the downsides of using a metaclass for this is that a given class can only have one metaclass. The error you're seeing there is telling you that both Django and Interface are trying to define a metaclass for your type, and python can't use both of them. I can think of two ways that interface could potentially try to solve this problem.
@check_implements(IContentSource)
class InstagramContentSource(ContentSource):
... This would work by doing the same checks that
meta = type(ContentSource)
class InstagramContentSource(ContentSource,
implements_with_meta(meta, IContentSource)):
class Meta:
proxy = True That's a lot more verbose, and the implementation would be more complex, but the upside of this would be that implementation checks would continue to propagate through subclasses. |
Here is another solution for this issue. Python 3.6 introduced a new method It is called automatically whenever a subclass is created and it gets in as a parameter the newly created subclass. So it has all the necessary data for performing the checks. Using this method, there is no need for a metaclass any more and thus the issue of metaclass conflicts will not arise. I am using this approach in a similar project and are very happy with this new Python feature :) |
I get the following error when using
implements()
with a Django model.Interface
Django Model
Interface Implementation
The text was updated successfully, but these errors were encountered: