11import asyncio
2- import inspect
32import logging
43import platform
5- import warnings
64from contextlib import suppress
75from dataclasses import dataclass , field as dataclass_field
86from functools import partial
2624from scrapy import Spider , signals , version_info as scrapy_version_info
2725from scrapy .core .downloader .handlers .http11 import HTTP11DownloadHandler
2826from scrapy .crawler import Crawler
29- from scrapy .exceptions import NotSupported , ScrapyDeprecationWarning
27+ from scrapy .exceptions import NotSupported
3028from scrapy .http import Request , Response
3129from scrapy .http .headers import Headers
3230from scrapy .responsetypes import responsetypes
@@ -782,11 +780,7 @@ async def _request_handler(route: Route, playwright_request: PlaywrightRequest)
782780
783781 if self .process_request_headers is None :
784782 final_headers = await playwright_request .all_headers ()
785- elif (sig := inspect .signature (self .process_request_headers )) and (
786- "browser_type_name" in sig .parameters
787- and "playwright_request" in sig .parameters
788- and "scrapy_request_data" in sig .parameters
789- ):
783+ else :
790784 overrides ["headers" ] = final_headers = await _maybe_await (
791785 self .process_request_headers (
792786 browser_type_name = self .config .browser_type_name ,
@@ -800,24 +794,6 @@ async def _request_handler(route: Route, playwright_request: PlaywrightRequest)
800794 },
801795 )
802796 )
803- else :
804- warnings .warn (
805- "Accepting positional arguments in the function passed to the"
806- " PLAYWRIGHT_PROCESS_REQUEST_HEADERS setting is deprecated. The function"
807- " should accept three (3) keyword arguments instead:"
808- " browser_type_name: str,"
809- " playwright_request: playwright.async_api.Request,"
810- " scrapy_request_data: dict" ,
811- category = ScrapyDeprecationWarning ,
812- stacklevel = 1 ,
813- )
814- overrides ["headers" ] = final_headers = await _maybe_await (
815- self .process_request_headers (
816- self .config .browser_type_name ,
817- playwright_request ,
818- headers ,
819- )
820- )
821797
822798 # if the current request corresponds to the original scrapy one
823799 if (
0 commit comments