mirror of https://github.com/scrapy/scrapy.git
Deprecate InitSpider (#6714)
This commit is contained in:
parent
1469b2739e
commit
044c3f69ed
|
|
@ -1,9 +1,11 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import warnings
|
||||
from collections.abc import Iterable
|
||||
from typing import TYPE_CHECKING, Any, cast
|
||||
|
||||
from scrapy import Request
|
||||
from scrapy.exceptions import ScrapyDeprecationWarning
|
||||
from scrapy.spiders import Spider
|
||||
from scrapy.utils.spider import iterate_spider_output
|
||||
|
||||
|
|
@ -12,7 +14,20 @@ if TYPE_CHECKING:
|
|||
|
||||
|
||||
class InitSpider(Spider):
|
||||
"""Base Spider with initialization facilities"""
|
||||
"""Base Spider with initialization facilities
|
||||
|
||||
.. warning:: This class is deprecated. Copy its code into your project if needed.
|
||||
It will be removed in a future Scrapy version.
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
warnings.warn(
|
||||
"InitSpider is deprecated. Copy its code from Scrapy's source if needed. "
|
||||
"Will be removed in a future version.",
|
||||
ScrapyDeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
|
||||
def start_requests(self) -> Iterable[Request]:
|
||||
self._postinit_reqs: Iterable[Request] = super().start_requests()
|
||||
|
|
|
|||
|
|
@ -144,6 +144,7 @@ class TestSpider(unittest.TestCase):
|
|||
mock_logger.log.assert_called_once_with("INFO", "test log msg")
|
||||
|
||||
|
||||
@pytest.mark.filterwarnings("ignore::scrapy.exceptions.ScrapyDeprecationWarning")
|
||||
class TestInitSpider(TestSpider):
|
||||
spider_class = InitSpider
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue