Use fancy kwarg typing

This commit is contained in:
Adrian Chaves 2026-03-12 16:49:29 +01:00
parent 9dfe449d13
commit 4d2071f7b3
1 changed files with 5 additions and 2 deletions

View File

@ -20,11 +20,14 @@ from scrapy.utils.url import strip_url
if TYPE_CHECKING:
# typing.Self requires Python 3.11
from typing_extensions import Self
from typing_extensions import Self, TypedDict, Unpack
from scrapy.crawler import Crawler
from scrapy.settings import BaseSettings
class _PolicyKwargs(TypedDict, total=False):
resp_or_url: Response | str
LOCAL_SCHEMES: tuple[str, ...] = (
"about",
@ -328,7 +331,7 @@ class RefererMiddleware(BaseSpiderMiddleware):
self,
response: Response | str | None = None,
request: Request | None = None,
**kwargs,
**kwargs: Unpack[_PolicyKwargs],
) -> ReferrerPolicy:
"""Return the referrer policy to use for *request* based on *request*
meta, *response* and settings.