Error When Calling The Metaclass Bases Metaclass Conflict
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About typeerror error when calling the metaclass bases multiple bases have instance lay-out conflict Us Learn more about Stack Overflow the company Business Learn more about hiring
Error When Calling The Metaclass Bases Takes At Most 2 Arguments
developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the error when calling the metaclass bases function() argument 1 must be code not str Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Triple inheritance causes metaclass conflict… Sometimes
Error When Calling The Metaclass Bases Module.__init__() Takes At Most 2 Arguments
up vote 32 down vote favorite 9 Looks like I stumbled upon a metaclass hell even when I didn't wanted anything to do with it. I'm writing an app in Qt4 using PySide. I want to separate event-driven part from UI definition, which is generated from Qt Designer files. Hence I create a "controller" classes, but to ease my life I multiple-inherit them anyways. An example: error when calling the metaclass bases python class BaseController(QObject): def setupEvents(self, parent): self.window = parent class MainController(BaseController): pass class MainWindow(QMainWindow, Ui_MainWindow, MainController): def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.setupUi(self) self.setupEvents(self) This works as expected. It also has inheritance from (QDialog, Ui_Dialog, BaseController). But when I subclass BaseController and try to inherit from said subclass (in place of BaseController), I receive an error: 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 Clarification: Both QMainWindow and QDialog inherit from QObject. BaseController must also inherit from it because of Qt event system peculiarities. Ui_ classes only inherit from simple Python object class. I searched for solutions, but all of them involve cases of intentionally using metaclasses. So I must be doing something terribly wrong. EDIT: My description may be clearer by adding graphs. Working example: QObject | \___________________ | object | QMainWindow | BaseController | /---Ui_MainWindow | | | MainController MainWindow-----------------/ Another working example: QObject | \___________________ | object | QDialog | BaseController | /---Ui_OtherWindow | | | | OtherWindow----------------/ Not working example: QObject | \___________________ | object | QDialog | BaseController | /---Ui_OtherWindow | | | OtherController OtherWind
Index PyPM Index Welcome, guest | Sign In | My Account |
Error When Calling The Metaclass Bases Module.__init__() Takes At Most 2 Arguments (3 Given)
Store | Cart ActiveState Code » Recipes Add a Recipe
Error When Calling The Metaclass Bases Cannot Create A Consistent Method Resolution
Languages Tags Authors Sets SOLVING THE METACLASS CONFLICT (Python recipe) by Michele Simionato ActiveState Code (http://code.activestate.com/recipes/204197/) typeerror error when calling the metaclass bases object() takes no parameters ▲ 6 ▼ Any serious user of metaclasses has been bitten at least once by the infamous metaclass/metatype conflict. Here I give a general recipe http://stackoverflow.com/questions/6557407/triple-inheritance-causes-metaclass-conflict-sometimes to solve the problem, as well as some theory and some examples. Python, 54 lines Download Copy to clipboard 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 http://code.activestate.com/recipes/204197-solving-the-metaclass-conflict/ 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 import inspect, types, __builtin__ ############## preliminary: two utility functions ##################### def skip_redundant(iterable, skipset=None): "Redundant items are repeated items or items in the original skipset." if skipset is None: skipset = set() for item in iterable: if item not in skipset: skipset.add(item) yield item def remove_redundant(metaclasses): skipset = set([types.ClassType]) for meta in metaclasses: # determines the metaclasses to be skipped skipset.update(inspect.getmro(meta)[1:]) return tuple(skip_redundant(metaclasses, skipset)) ################################################################## ## now the core of the module: two mutually recursive functions ## ################################################################## memoized_metaclasses_map = {} def get_noconflict_metaclass(bases, left_metas, right_metas): """Not intended to be used outside of this module, unless you know what you are doing.""" # make tuple of needed metaclasses in specified priority order metas = left_metas + tuple(map(type, bases)) + right_metas needed_metas = remove_redundant(metas) # return existing confict-solving meta, if any if n
Sign in Pricing Blog Support Search https://github.com/divio/django-cms/issues/2114 GitHub This repository Watch 312 Star 4,459 https://github.com/tensorflow/tensorflow/issues/487 Fork 1,687 divio/django-cms Code Issues 168 Pull requests 10 Projects 0 Pulse Graphs New issue metaclass conflict with Django 1.6 (latest django-cms develop branch) #2114 Closed stefanocrosta opened this Issue Jul 31, 2013 error when · 25 comments Projects None yet Labels None yet Milestone No milestone Assignees No one assigned 9 participants stefanocrosta commented Jul 31, 2013 I admit I tried to to do something with this but it's far too advanced error when calling python for me, due to the dynamic metaclass inheritance... I'm also not sure if Django is to blame, or django-cms... File "/home/stefano/django/django/utils/autoreload.py", line 93, in wrapper fn(*args, **kwargs) File "/home/stefano/django/django/core/management/commands/runserver.py", line 97, in inner_run self.validate(display_num_errors=True) File "/home/stefano/django/django/core/management/base.py", line 308, in validate num_errors = get_validation_errors(s, app) File "/home/stefano/django/django/core/management/validation.py", line 34, in get_validation_errors for (app_name, error) in get_app_errors().items(): File "/home/stefano/django/django/db/models/loading.py", line 196, in get_app_errors self._populate() File "/home/stefano/django/django/db/models/loading.py", line 75, in _populate self.load_app(app_name, True) File "/home/stefano/django/django/db/models/loading.py", line 99, in load_app models = import_module('.models', app_name) File "/home/stefano/django/django/utils/importlib.py", line 35, in import_module __import__(name) File "/home/stefano/django-cms/cms/stacks/models.py", line 7, in
Sign in Pricing Blog Support Search GitHub This repository Watch 3,221 Star 34,281 Fork 15,090 tensorflow/tensorflow Code Issues 573 Pull requests 44 Projects 0 Pulse Graphs New issue TypeError: metaclass conflict in Python 2 and 3 #487 Closed pronobis opened this Issue Dec 12, 2015 · 19 comments Projects None yet Labels None yet Milestone No milestone Assignees No one assigned 16 participants pronobis commented Dec 12, 2015 TF 0.6.0 installed using PIP gives the following error on import in both Python 2 and 3: >>> import tensorflow Traceback (most recent call last): File "