Skip to content

ABCMeta and @abstractmethod suppose to work? #30

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

Open
alanjds opened this issue Aug 21, 2018 · 2 comments
Open

ABCMeta and @abstractmethod suppose to work? #30

alanjds opened this issue Aug 21, 2018 · 2 comments
Labels
imported Imported from google/grumpy

Comments

@alanjds
Copy link

alanjds commented Aug 21, 2018

google#199 opened by @S-YOU on 23 Jan 2017

I don't get OrderedDict working, because I am getting error on

self.__update(*args, **kwds)
TypeError: unbound method update() must be called with MutableMapping instance as first argument (got list instance instead)

self.__update is assigned to MutableMapping.update at class level.

It is not possible to get instance of MutableMapping, because there is abstractmethods on it.

TypeError: Can't instantiate abstract class MutableMapping with abstract methods __delitem__, __getitem__, __iter__, __len__, __setitem__

Is there a way to work-around those?

@alanjds
Copy link
Author

alanjds commented Aug 21, 2018

Comment by trotterdylan
Monday Jan 23, 2017 at 23:50 GMT


I'm surprised that works in CPython. Here's something similar that fails:

>>> class A(object):
...  def foo(self):
...   pass
...
>>> class B(object):
...  bar = A.foo
...
>>> B().bar()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unbound method foo() must be called with A instance as first argument (got nothing instead)

I'm not exactly sure what's going on. Will need to do some more investigation.

@alanjds
Copy link
Author

alanjds commented Aug 21, 2018

Comment by S-YOU
Tuesday Jan 24, 2017 at 00:30 GMT


May be MutableMapping.register(dict) does something monkey patching.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
imported Imported from google/grumpy
Projects
None yet
Development

No branches or pull requests

1 participant