Skip to content

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

docs: use "constructor" for from_settings() & rom_crawler() factory methods

Ammar Najjar7a84a4bdba45
diff --git a/scrapy/utils/misc.py b/scrapy/utils/misc.py
index 8060553ad..f638adb25 100644
--- a/scrapy/utils/misc.py
+++ b/scrapy/utils/misc.py
@@ -123,14 +123,14 @@ def rel_has_nofollow(rel):
def create_instance(objcls, settings, crawler, *args, **kwargs):
"""Construct a class instance using its ``from_crawler`` or
- ``from_settings`` ``__init__`` methods, if available.
+ ``from_settings`` constructors, if available.
At least one of ``settings`` and ``crawler`` needs to be different from
``None``. If ``settings `` is ``None``, ``crawler.settings`` will be used.
- If ``crawler`` is ``None``, only the ``from_settings`` ``__init__`` method will be
+ If ``crawler`` is ``None``, only the ``from_settings`` constructor will be
tried.
- ``*args`` and ``**kwargs`` are forwarded to the ``__init__`` methods.
+ ``*args`` and ``**kwargs`` are forwarded to the constructors.
Raises ``ValueError`` if both ``settings`` and ``crawler`` are ``None``.
"""
diff --git a/tests/test_utils_misc/__init__.py b/tests/test_utils_misc/__init__.py
index 457a2aa78..e109d5343 100644
--- a/tests/test_utils_misc/__init__.py
+++ b/tests/test_utils_misc/__init__.py
@@ -109,11 +109,11 @@ class UtilsMiscTestCase(unittest.TestCase):
else:
mock.assert_called_once_with(*args, **kwargs)
- # Check usage of correct __init__ method using four mocks:
- # 1. with no alternative __init__ methods
- # 2. with from_settings() __init__ method
- # 3. with from_crawler() __init__ method
- # 4. with from_settings() and from_crawler() __init__ method
+ # Check usage of correct constructor using four mocks:
+ # 1. with no alternative constructors
+ # 2. with from_settings() constructor
+ # 3. with from_crawler() constructor
+ # 4. with from_settings() and from_crawler() constructor
spec_sets = ([], ['from_settings'], ['from_crawler'],
['from_settings', 'from_crawler'])
for specs in spec_sets: