Skip to content

Make @implementer and classImplements not add redundant interfaces #203

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

Merged
merged 3 commits into from
Apr 8, 2020

Conversation

jamadden
Copy link
Member

@jamadden jamadden commented Apr 6, 2020

The plone buildout.coredev tests all pass, with the exception of 8 tests from plone.app.caching.tests.test_etags. They all fail like this:

Error in test test_Roles_member (plone.app.caching.tests.test_etags.TestETags)
Traceback (most recent call last):
  File "//2.7/lib/python2.7/unittest/case.py", line 329, in run
    testMethod()
  File "//plone.app.caching-2.0.4-py2.7.egg/plone/app/caching/tests/test_etags.py", line 144, in test_Roles_member
    provideAdapter(DummyPortalState, name=u'plone_portal_state')
  File "//zope.component-4.5-py2.7.egg/zope/component/globalregistry.py", line 73, in provideAdapter
    base.registerAdapter(factory, adapts, provides, name, event=False)
  File "//src/zope.interface/src/zope/interface/registry.py", line 305, in registerAdapter
    provided = _getAdapterProvided(factory)
  File "//src/zope.interface/src/zope/interface/registry.py", line 528, in _getAdapterProvided
    "The adapter factory doesn't implement a single interface "
TypeError: The adapter factory doesn't implement a single interface and no provided interface was specified.

That's with code like this:

       @implementer(Interface)
       @adapter(DummyContext, Interface)
        class DummyPortalState(object):

            def __init__(self, context, request):
                pass

            def language(self):
                return 'en'

        provideAdapter(DummyPortalState, name=u'plone_portal_state')

Something is going wrong with @implementer(Interface)...

@jamadden jamadden marked this pull request as ready for review April 6, 2020 17:06
@jamadden
Copy link
Member Author

jamadden commented Apr 6, 2020

Latest commits make plone's buildout.coredev green for me. Currently based on #202.

@jamadden jamadden changed the title WIP: Make @implementer and classImplements not add redundant interfaces Make @implementer and classImplements not add redundant interfaces Apr 7, 2020
jamadden added 3 commits April 7, 2020 07:32
…aces.

classImplementsOnly and @implementer_only can still be used to do that.
…ip the redundancy detection for the sake of plone.app.caching.
…ent.

Seen in plone.app.testing as a problem in Products.GenericSetup.

Added tests for that.
@jamadden
Copy link
Member Author

jamadden commented Apr 7, 2020

Rebased on master.

Copy link
Member

@mgedmin mgedmin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

new_declared.append(b)
seen.add(b)
for l in before, spec.declared, after:
for b in l:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does pylint not complain about using lowercase-ell as a variable name?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It probably would, but the check for valid names has to be disabled when working in zope repos because the false positives are overwhelming. (It's not the first one-letter temporary variable in this file.)

image

@jamadden jamadden merged commit 76203eb into master Apr 8, 2020
@jamadden jamadden deleted the issue199 branch April 8, 2020 12:18
@jamadden
Copy link
Member Author

jamadden commented Apr 8, 2020

Thank you.

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

Successfully merging this pull request may close these issues.

2 participants