-
Notifications
You must be signed in to change notification settings - Fork 273
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
metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases #210
Comments
Just stumbled onto this as well. Not using |
A minimal non-working example would be nice. |
Looking at the 3rd party package code that triggers the error, it boils down to this:
Removing the |
Obviously, that is the right fix. The whole point of using That being said, if this broke actual usage (even if that actual usage is arguably wrong), it makes sense to try to fix this. |
This is obviously unrelated to this issue, it seems more like an installation issue. |
I'll create a pull request to remove the |
I could probably manage to fix the
example but it will lead to more complicated code for I would like some input from the |
I have the same issue with some Google libraries:
|
The issue in # TODO(rafek): Prevent additional field subclasses.
class Field(six.with_metaclass(_FieldMeta, object)):
"""Definition for message field."""
__initialized = False # pylint:disable=invalid-name
__variant_to_type = {} # pylint:disable=invalid-name
# TODO(craigcitro): Remove this alias.
#
# We add an alias here for backwards compatibility; note that in
# python3, this attribute will silently be ignored.
__metaclass__ = _FieldMeta |
Got the same issue using a Django package.
|
Which version of django-autocomplete-light is that? |
django-autocomplete-light 2.3.3 |
Same issue with django-autocomplete-light 2.3.3: class ModelForm(six.with_metaclass(*bases)):
"""
ModelForm override using our metaclass that adds our various mixins.
.. py:attribute:: autocomplete_fields
A list of field names on which you want automatic autocomplete fields.
.. py:attribute:: autocomplete_exclude
A list of field names on which you do not want automatic autocomplete
fields.
.. py:attribute:: autocomplete_names
A dict of ``field_name: AutocompleteName`` to override the default
autocomplete that would be used for a field.
Note: all of ``autocomplete_fields``, ``autocomplete_exclude`` and
``autocomplete_names`` understand generic foreign key and generic many to
many descriptor names.
"""
__metaclass__ = ModelFormMetaclass |
same for me using the module boxsdk. just need to: et bim:
using six 1.10.0 there is no problem. |
def with_metaclass(meta, *bases, **with_metaclass_kwargs):
"""Extends the behavior of six.with_metaclass.
[...]
"""
temporary_class = six.with_metaclass(meta, *bases, **with_metaclass_kwargs)
temporary_metaclass = type(temporary_class)
class TemporaryMetaSubclass(temporary_metaclass):
@classmethod
def __prepare__(cls, name, this_bases, **kwds): # pylint:disable=unused-argument
return meta.__prepare__(name, bases, **kwds)
return type.__new__(TemporaryMetaSubclass, str('temporary_class'), bases, {}) This is using It would be better if |
I have the same issue with the pywbem project. I can circumvent the issue by pinning the six version to 0.10.0, for the time being. File
With six 1.11.0:
|
As discussed above, this is wrong: you should not combine |
Details: The `PywbemLoggers` class was defined by inheriting from `six.with_metaclass(MetaPywbemLoggers)` and it also defined the `__metaclass__` attribute. Version 0.11.0 of the `six` package does not deal with this anymore and raises: TypeError: Error when calling the metaclass bases metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases This change removes setting the `__metaclass__` attribute, which is not needed anyway when using `six.with_metaclass()`, and which is (or will at some point?) no longer supported in Python 3. See also discussion in six issue #210: benjaminp/six#210 Signed-off-by: Andreas Maier <[email protected]>
@jdemeyer Hi, I'm sorry for having overlooked the advice above. After removing the setting of the Having said that, |
Version constrain six see benjaminp/six#210
I have a fix for the |
What is "this"? There is no bug in For the record in case it's not clear: I am not a |
Upstream bugs being tracked at google/apitools#175 and benjaminp/six#210
With so many different projects impacted by #191, often its best to revert the commit in question and cut a point release to mitigate the issue. Reverts are easier to get in. Later, you can write and discuss a new implementation with the maintainers and if there really is a breaking change, draft a changelog note about it. |
Please can we release a version with the revert? This is impacting several projects (latest of which being SecurityInnovation/PGPy#217), and whilst it's their fault for incorrect usage, it's clearly a surprisingly common pattern, and has caught people off-guard due to it occurring in a minor version without a mention of breakage in the release notes. Many thanks :-) |
Or just apply my patch from #211. |
The quoted text explains why a revert would be preferable in the meantime :-) |
I think we're already past that timeframe :-) Anyway, I'm not disagreeing here: I just wanted to re-advertise my fix in case somebody missed it. In any case, it will be a maintainer of |
Still learning my way about use of metaclass so IIUC, we should not be using but we are fine to use or the later also should not be used? Thanks in adv ! |
Cleaning up my open issues. |
Some time in the last 12 hours, our build system using
gsutil
started failing and it appears to be related tosix
1.11.0, which was just released.gsutil
declares a dependency on six>=1.9.0 (ugh) so it pulls in the just released 1.11.0. Rolling back to six 1.10.0 and gsutil runs alright. I'm not really involved in Python or gsutil, so maybe gsutil needs to fix something, no idea, but it seems like a breakage that's not called out in the release notes or maybe something to fix.cc @jdemeyer @benjaminp
Possibly introduced in #191
The text was updated successfully, but these errors were encountered: