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

verifyObject doesn't verify keyword arguments #140

Open
jluttine opened this issue Jun 14, 2019 · 4 comments
Open

verifyObject doesn't verify keyword arguments #140

jluttine opened this issue Jun 14, 2019 · 4 comments

Comments

@jluttine
Copy link

jluttine commented Jun 14, 2019

Given the following:

class IFoo(zope.interface.Interface):
    def bar(lorem="ipsum", alice=42):
        """ ... """

@zope.interface.implementer(IFoo)
class Foo():
    def bar(self, x=666, y=99):
        return x + y

I would have expected verification to fail but it doesn't:

>>> zope.interface.verify.verifyObject(IFoo, Foo())
True

How can I force verifyObject to verify the function signature exactly? So that it it is exactly the same (same positional and keyword arguments with same names in same order and also the same *args and **kwargs).

@d-maurer
Copy link
Contributor

d-maurer commented Jun 14, 2019 via email

@icemac
Copy link
Member

icemac commented Jun 21, 2019

See #63 for some details. Maybe at least some parts of the issue can be fixed via a PR.

@d-maurer
Copy link
Contributor

See #63 for some details. Maybe at least some parts of the issue can be fixed via a PR.

Will zope.interface drop Python 2 support soon?
After there is only Python 3, zope.interface should (of course) support Python 3's new keyword only arguments (and for them check that they do not change names).

I am against checking the names of positional arguments - whether with or without toggle: a positional argument is defined by its position not by its name. If I want an argument defined by name, I use a keyword only argument (provided I can do this because I support only Python 3).

@icemac
Copy link
Member

icemac commented Jun 25, 2019

From 2020-01-01 on there is no need to support Python 2.7 any more. (People needing Python 2 support can still use older package versions.)

rodrigc added a commit to twisted/twisted that referenced this issue Jul 9, 2020
[mypy] [9897] Rename parameters to match interface definitions

This is related to these issues in zope.interface:

* zopefoundation/zope.interface#63
* zopefoundation/zope.interface#140

Author: rodrigc
Reviewer: adiroiban
Fixes: ticket:9897
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants