Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

Make AddonManager.add() private.

Andrey Rakhmatullin5c34f34ecbc1
diff --git a/scrapy/addons.py b/scrapy/addons.py
index 612c7effc..812892613 100644
--- a/scrapy/addons.py
+++ b/scrapy/addons.py
@@ -17,15 +17,8 @@ class AddonManager:
self.crawler: "Crawler" = crawler
self.addons: List[Any] = []
- def add(self, addon: Any) -> None:
- """Store an add-on.
-
- :param addon: The add-on object (or path) to be stored
- :type addon: Python object, class or ``str``
-
- :param config: The add-on configuration dictionary
- :type config: ``dict``
- """
+ def _add(self, addon: Any) -> None:
+ """Store an add-on."""
if isinstance(addon, (type, str)):
addon = load_object(addon)
if isinstance(addon, type):
@@ -33,7 +26,7 @@ class AddonManager:
self.addons.append(addon)
def load_settings(self, settings) -> None:
- """Load add-ons and configurations from settings object.
+ """Load add-ons and configurations from a settings object.
This will load the addon for every add-on path in the
``ADDONS`` setting.
@@ -42,10 +35,9 @@ class AddonManager:
which to read the add-on configuration
:type settings: :class:`~scrapy.settings.Settings`
"""
- paths = build_component_list(settings["ADDONS"])
- addons = [load_object(path) for path in paths]
- for a in addons:
- self.add(a)
+ addons = build_component_list(settings["ADDONS"])
+ for addon in build_component_list(settings["ADDONS"]):
+ self._add(addon)
logger.info(
"Enabled addons:\n%(addons)s",
{
diff --git a/tests/test_addons.py b/tests/test_addons.py
index d52665869..95377d718 100644
--- a/tests/test_addons.py
+++ b/tests/test_addons.py
@@ -43,12 +43,6 @@ class AddonTest(unittest.TestCase):
class AddonManagerTest(unittest.TestCase):
- def test_add(self):
- crawler = get_crawler()
- manager = crawler.addons
- manager.add("tests.test_addons.GoodAddon")
- self.assertIsInstance(manager.addons[0], GoodAddon)
-
def test_load_settings(self):
settings_dict = {
"ADDONS": {"tests.test_addons.GoodAddon": 0},