1
1
import asyncio
2
- import inspect
3
2
import logging
4
3
import platform
5
- import warnings
6
4
from contextlib import suppress
7
5
from dataclasses import dataclass , field as dataclass_field
8
6
from functools import partial
26
24
from scrapy import Spider , signals
27
25
from scrapy .core .downloader .handlers .http import HTTPDownloadHandler
28
26
from scrapy .crawler import Crawler
29
- from scrapy .exceptions import NotSupported , ScrapyDeprecationWarning
27
+ from scrapy .exceptions import NotSupported
30
28
from scrapy .http import Request , Response
31
29
from scrapy .http .headers import Headers
32
30
from scrapy .responsetypes import responsetypes
@@ -736,11 +734,7 @@ async def _request_handler(route: Route, playwright_request: PlaywrightRequest)
736
734
737
735
if self .process_request_headers is None :
738
736
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 :
744
738
overrides ["headers" ] = final_headers = await _maybe_await (
745
739
self .process_request_headers (
746
740
browser_type_name = self .config .browser_type_name ,
@@ -754,24 +748,6 @@ async def _request_handler(route: Route, playwright_request: PlaywrightRequest)
754
748
},
755
749
)
756
750
)
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
- )
775
751
776
752
# if the current request corresponds to the original scrapy one
777
753
if (
0 commit comments