summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Madden <jamadden@gmail.com>2021-03-18 12:18:26 -0500
committerGitHub <noreply@github.com>2021-03-18 12:18:26 -0500
commit5fd805db518f978dba1498a759dd796791dd4d1f (patch)
tree62a6189b8c6c4cbd8a9fa93a2edfb3a8bc094807
parent41cafd34b01555bc5c8bb7fe1b6181a7acf32fe7 (diff)
parent968ccad5f7e0c5417fb3908cf431e17da3beac50 (diff)
downloadzope-component-5fd805db518f978dba1498a759dd796791dd4d1f.tar.gz
Merge pull request #60 from zopefoundation/issue59
Remove backwards compatibility imports.
-rw-r--r--CHANGES.rst9
-rw-r--r--setup.py2
-rw-r--r--src/zope/component/hookable.py19
-rw-r--r--src/zope/component/interfaces.py28
-rw-r--r--src/zope/component/registry.py16
-rw-r--r--src/zope/component/tests/test_interfaces.py40
-rw-r--r--src/zope/component/tests/test_registry.py27
7 files changed, 19 insertions, 122 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index 84a0faa..1f36963 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -5,6 +5,15 @@
5.0.0 (unreleased)
==================
+- Remove backwards compatibility imports that were emitting
+ deprecation warnings. This affects certain imports from
+ ``zope.component.interfaces`` (which should be imported from
+ ``zope.interface.interfaces``) as well as certain imports from
+ ``zope.component.registery`` (import from
+ ``zope.interface.registry``), and the entire
+ ``zope.component.hookable`` module. See `issue 59
+ <https://github.com/zopefoundation/zope.component/issues/59>`_.
+
- Respect permission value for utility factory registrations
(`#54 <https://github.com/zopefoundation/zope.component/issues/54>`_)
diff --git a/setup.py b/setup.py
index 8a5c877..50dbeb5 100644
--- a/setup.py
+++ b/setup.py
@@ -107,8 +107,6 @@ setup(
tests_require=TESTS_REQUIRE,
install_requires=[
'setuptools',
- 'zope.deferredimport >= 4.2.1',
- 'zope.deprecation >= 4.3.0',
'zope.event',
'zope.hookable >= 4.2.0',
'zope.interface >= 4.1.0',
diff --git a/src/zope/component/hookable.py b/src/zope/component/hookable.py
deleted file mode 100644
index 275c4b6..0000000
--- a/src/zope/component/hookable.py
+++ /dev/null
@@ -1,19 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2009 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""
-This module is deprecated. Prefer to use zope.hookable.hookable.
-"""
-# pragma: no cover
-import zope.deprecation
-zope.deprecation.moved("zope.hookable", "4.5")
diff --git a/src/zope/component/interfaces.py b/src/zope/component/interfaces.py
index 15fbb55..068c625 100644
--- a/src/zope/component/interfaces.py
+++ b/src/zope/component/interfaces.py
@@ -20,33 +20,7 @@ are provided by `zope.component` directly.
from zope.interface import Attribute
from zope.interface import Interface
-
-# BBB 2011-09-09, import interfaces from zope.interface
-import zope.deferredimport
-zope.deferredimport.deprecatedFrom(
- "Import from zope.interface.interfaces",
- "zope.interface.interfaces",
- 'ComponentLookupError',
- 'Invalid',
- 'IObjectEvent',
- 'ObjectEvent',
- 'IComponentLookup',
- 'IRegistration',
- 'IUtilityRegistration',
- '_IBaseAdapterRegistration',
- 'IAdapterRegistration',
- 'ISubscriptionAdapterRegistration',
- 'IHandlerRegistration',
- 'IRegistrationEvent',
- 'RegistrationEvent',
- 'IRegistered',
- 'Registered',
- 'IUnregistered',
- 'Unregistered',
- 'IComponentRegistry',
- 'IComponents',
-)
-
+# pylint:disable=inherit-non-class,no-self-argument,no-method-argument
class IComponentArchitecture(Interface):
"""The Component Architecture is defined by two key components: Adapters
diff --git a/src/zope/component/registry.py b/src/zope/component/registry.py
index 6c0c47c..2eb3d6b 100644
--- a/src/zope/component/registry.py
+++ b/src/zope/component/registry.py
@@ -23,22 +23,6 @@ from zope.interface.interfaces import IRegistrationEvent
from zope.interface.interfaces import ISubscriptionAdapterRegistration
from zope.interface.interfaces import IUtilityRegistration
-# BBB, import component-related from zope.interface
-import zope.deferredimport
-zope.deferredimport.deprecatedFrom(
- "Import from zope.interface.registry",
- "zope.interface.registry",
- 'Components',
- '_getUtilityProvided',
- '_getAdapterProvided',
- '_getAdapterRequired',
- 'UtilityRegistration',
- 'AdapterRegistration',
- 'SubscriptionRegistration',
- 'HandlerRegistration',
-)
-
-
@adapter(IUtilityRegistration, IRegistrationEvent)
def dispatchUtilityRegistrationEvent(registration, event):
handle(registration.component, event)
diff --git a/src/zope/component/tests/test_interfaces.py b/src/zope/component/tests/test_interfaces.py
index 353a212..4d1794d 100644
--- a/src/zope/component/tests/test_interfaces.py
+++ b/src/zope/component/tests/test_interfaces.py
@@ -17,37 +17,13 @@ Tests for zope.component.interfaces
import unittest
-class TestBackwardsCompat(unittest.TestCase):
+class TestInterfaces(unittest.TestCase):
- def test_interface_warnings(self):
- from zope.component import interfaces
- import warnings
- for name in (
- 'ComponentLookupError',
- 'Invalid',
- 'IObjectEvent',
- 'ObjectEvent',
- 'IComponentLookup',
- 'IRegistration',
- 'IUtilityRegistration',
- '_IBaseAdapterRegistration',
- 'IAdapterRegistration',
- 'ISubscriptionAdapterRegistration',
- 'IHandlerRegistration',
- 'IRegistrationEvent',
- 'RegistrationEvent',
- 'IRegistered',
- 'Registered',
- 'IUnregistered',
- 'Unregistered',
- 'IComponentRegistry',
- 'IComponents',
- ):
- with warnings.catch_warnings(record=True) as log:
- warnings.simplefilter("always")
- getattr(interfaces, name)
+ def test_nothing(self):
+ """
+ This exists only so that zope.testrunner doesn't complain this
+ module has no tests.
- self.assertEqual(1, len(log), name)
- message = str(log[0].message)
- self.assertIn(name, message)
- self.assertIn("Import from zope.interface.interfaces", message)
+ Even though this file is empty, we want to keep it around for ease
+ of browsing the history.
+ """
diff --git a/src/zope/component/tests/test_registry.py b/src/zope/component/tests/test_registry.py
index 39f9f3c..1d02f86 100644
--- a/src/zope/component/tests/test_registry.py
+++ b/src/zope/component/tests/test_registry.py
@@ -105,36 +105,11 @@ class Test_dispatchHandlerRegistrationEvent(unittest.TestCase):
self.assertEqual(_handled, [(_registration.handler, _EVENT)])
-class TestBackwardsCompat(unittest.TestCase):
-
- def test_interface_warnings(self):
- from zope.component import registry
- import warnings
- for name in (
- 'Components',
- '_getUtilityProvided',
- '_getAdapterProvided',
- '_getAdapterRequired',
- 'UtilityRegistration',
- 'AdapterRegistration',
- 'SubscriptionRegistration',
- 'HandlerRegistration',
- ):
- with warnings.catch_warnings(record=True) as log:
- warnings.simplefilter("always")
- getattr(registry, name)
-
- self.assertEqual(1, len(log), name)
- message = str(log[0].message)
- self.assertIn(name, message)
- self.assertIn("Import from zope.interface.registry", message)
-
-
class _Monkey(object):
# context-manager for replacing module names in the scope of a test.
def __init__(self, module, **kw):
self.module = module
- self.to_restore = dict([(key, getattr(module, key)) for key in kw])
+ self.to_restore = {key: getattr(module, key) for key in kw}
for key, value in kw.items():
setattr(module, key, value)