Skip to content
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

BrokenMethodImplementation "doesn't allow enough arguments" error when using staticmethods on Python 3 #126

Closed
rouge8 opened this issue Oct 23, 2018 · 0 comments
Labels

Comments

@rouge8
Copy link

rouge8 commented Oct 23, 2018

Verifying a class using @provider behaves differently on Python 2.7 vs. Python 3.7 with zope.interface 4.5.0:

import zope.interface
from zope.interface.verify import verifyObject

class IFoo(zope.interface.Interface):
    def bar(a, b):
        pass

@zope.interface.provider(IFoo)
class Foo(object):
    @staticmethod
    def bar(a, b):
        pass

assert verifyObject(IFoo, Foo)

On Python 2.7, this code passes. On Python 3.7 it raises a BrokenMethodImplementation:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/andy/test/.tox/py37/lib/python3.7/site-packages/zope/interface/verify.py", line 105, in verifyObject
    return _verify(iface, candidate, tentative, vtype='o')
  File "/Users/andy/test/.tox/py37/lib/python3.7/site-packages/zope/interface/verify.py", line 97, in _verify
    raise BrokenMethodImplementation(name, mess)
zope.interface.exceptions.BrokenMethodImplementation: The implementation of bar violates its contract
        because implementation doesn't allow enough arguments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants