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
2725from scrapy .core .downloader .handlers .http import HTTPDownloadHandler
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
@@ -736,11 +734,7 @@ async def _request_handler(route: Route, playwright_request: PlaywrightRequest)
736734
737735 if self .process_request_headers is None :
738736 final_headers = await playwright_request .all_headers ()
739- elif (sig := inspect .signature (self .process_request_headers )) and (
740- "browser_type_name" in sig .parameters
741- and "playwright_request" in sig .parameters
742- and "scrapy_request_data" in sig .parameters
743- ):
737+ else :
744738 overrides ["headers" ] = final_headers = await _maybe_await (
745739 self .process_request_headers (
746740 browser_type_name = self .config .browser_type_name ,
@@ -754,24 +748,6 @@ async def _request_handler(route: Route, playwright_request: PlaywrightRequest)
754748 },
755749 )
756750 )
757- else :
758- warnings .warn (
759- "Accepting positional arguments in the function passed to the"
760- " PLAYWRIGHT_PROCESS_REQUEST_HEADERS setting is deprecated. The function"
761- " should accept three (3) keyword arguments instead:"
762- " browser_type_name: str,"
763- " playwright_request: playwright.async_api.Request,"
764- " scrapy_request_data: dict" ,
765- category = ScrapyDeprecationWarning ,
766- stacklevel = 1 ,
767- )
768- overrides ["headers" ] = final_headers = await _maybe_await (
769- self .process_request_headers (
770- self .config .browser_type_name ,
771- playwright_request ,
772- headers ,
773- )
774- )
775751
776752 # if the current request corresponds to the original scrapy one
777753 if (
0 commit comments