Scrapy, a fast high-level web crawling & scraping framework for Python.
Address PR feedback.
Andrey Rakhmatullin929d665a7433
diff --git a/scrapy/middleware.py b/scrapy/middleware.pyindex 91411506f..2b67dcd21 100644--- a/scrapy/middleware.py+++ b/scrapy/middleware.py@@ -54,14 +54,6 @@ class MiddlewareManager:@staticmethoddef _build_from_settings(objcls: type[_T], settings: BaseSettings) -> _T:if hasattr(objcls, "from_settings"):- warnings.warn(- f"{objcls.__qualname__} has from_settings() but not from_crawler()."- " This is deprecated and calling from_settings() will be removed in a future"- " Scrapy version. You can implement a simple from_crawler() that calls"- " from_settings() with crawler.settings.",- category=ScrapyDeprecationWarning,- stacklevel=2,- )instance = objcls.from_settings(settings) # type: ignore[attr-defined]method_name = "from_settings"else:diff --git a/scrapy/pipelines/files.py b/scrapy/pipelines/files.pyindex 065d822f3..196b54acb 100644--- a/scrapy/pipelines/files.py+++ b/scrapy/pipelines/files.py@@ -35,7 +35,7 @@ from scrapy.utils.datatypes import CaseInsensitiveDictfrom scrapy.utils.deprecate import method_is_overriddenfrom scrapy.utils.ftp import ftp_store_filefrom scrapy.utils.log import failure_to_exc_info-from scrapy.utils.python import get_func_args, to_bytes+from scrapy.utils.python import get_func_args, global_object_name, to_bytesfrom scrapy.utils.request import referer_strif TYPE_CHECKING:@@ -457,7 +457,7 @@ class FilesPipeline(MediaPipeline):if settings is not None:warnings.warn(f"FilesPipeline.__init__() was called with a crawler instance and a settings instance"- f" when creating {self.__class__.__qualname__}. The settings instance will be ignored"+ f" when creating {global_object_name(self.__class__)}. The settings instance will be ignored"f" and crawler.settings will be used. The settings argument will be removed in a future Scrapy version.",category=ScrapyDeprecationWarning,stacklevel=2,@@ -501,7 +501,7 @@ class FilesPipeline(MediaPipeline):def from_crawler(cls, crawler: Crawler) -> Self:if method_is_overridden(cls, FilesPipeline, "from_settings"):warnings.warn(- f"{cls.__name__} overrides FilesPipeline.from_settings()."+ f"{global_object_name(cls)} overrides FilesPipeline.from_settings()."f" This method is deprecated and won't be called in future Scrapy versions,"f" please update your code so that it overrides from_crawler() instead.",category=ScrapyDeprecationWarning,@@ -522,7 +522,7 @@ class FilesPipeline(MediaPipeline):if crawler:o._finish_init(crawler)warnings.warn(- f"{cls.__qualname__}.__init__() doesn't take a crawler argument."+ f"{global_object_name(cls)}.__init__() doesn't take a crawler argument."" This is deprecated and the argument will be required in future Scrapy versions.",category=ScrapyDeprecationWarning,)diff --git a/scrapy/pipelines/images.py b/scrapy/pipelines/images.pyindex 7defafb26..e86e7c493 100644--- a/scrapy/pipelines/images.py+++ b/scrapy/pipelines/images.py@@ -20,7 +20,7 @@ from scrapy.http import Request, Responsefrom scrapy.http.request import NO_CALLBACKfrom scrapy.pipelines.files import FileException, FilesPipeline, _md5sumfrom scrapy.settings import Settings-from scrapy.utils.python import get_func_args, to_bytes+from scrapy.utils.python import get_func_args, global_object_name, to_bytesif TYPE_CHECKING:from collections.abc import Callable, Iterable@@ -82,7 +82,7 @@ class ImagesPipeline(FilesPipeline):if settings is not None:warnings.warn(f"ImagesPipeline.__init__() was called with a crawler instance and a settings instance"- f" when creating {self.__class__.__qualname__}. The settings instance will be ignored"+ f" when creating {global_object_name(self.__class__)}. The settings instance will be ignored"f" and crawler.settings will be used. The settings argument will be removed in a future Scrapy version.",category=ScrapyDeprecationWarning,stacklevel=2,@@ -130,7 +130,7 @@ class ImagesPipeline(FilesPipeline):if crawler:o._finish_init(crawler)warnings.warn(- f"{cls.__qualname__}.__init__() doesn't take a crawler argument."+ f"{global_object_name(cls)}.__init__() doesn't take a crawler argument."" This is deprecated and the argument will be required in future Scrapy versions.",category=ScrapyDeprecationWarning,)diff --git a/scrapy/pipelines/media.py b/scrapy/pipelines/media.pyindex 70c52d090..6d7808c31 100644--- a/scrapy/pipelines/media.py+++ b/scrapy/pipelines/media.py@@ -28,7 +28,7 @@ from scrapy.utils.datatypes import SequenceExcludefrom scrapy.utils.defer import defer_result, mustbe_deferredfrom scrapy.utils.log import failure_to_exc_infofrom scrapy.utils.misc import arg_to_iter-from scrapy.utils.python import get_func_args+from scrapy.utils.python import get_func_args, global_object_nameif TYPE_CHECKING:from collections.abc import Callable@@ -85,7 +85,7 @@ class MediaPipeline(ABC):if settings is not None:warnings.warn(f"MediaPipeline.__init__() was called with a crawler instance and a settings instance"- f" when creating {self.__class__.__qualname__}. The settings instance will be ignored"+ f" when creating {global_object_name(self.__class__)}. The settings instance will be ignored"f" and crawler.settings will be used. The settings argument will be removed in a future Scrapy version.",category=ScrapyDeprecationWarning,stacklevel=2,@@ -107,7 +107,7 @@ class MediaPipeline(ABC):else:warnings.warn(f"MediaPipeline.__init__() was called without the crawler argument"- f" when creating {self.__class__.__qualname__}."+ f" when creating {global_object_name(self.__class__)}."f" This is deprecated and the argument will be required in future Scrapy versions.",category=ScrapyDeprecationWarning,stacklevel=2,@@ -154,7 +154,7 @@ class MediaPipeline(ABC):else:pipe = cls()warnings.warn(- f"{cls.__qualname__}.__init__() doesn't take a crawler argument."+ f"{global_object_name(cls)}.__init__() doesn't take a crawler argument."" This is deprecated and the argument will be required in future Scrapy versions.",category=ScrapyDeprecationWarning,)