Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

Replace return type

Eugenio Lacuestace6447731a91
diff --git a/scrapy/http/request/__init__.py b/scrapy/http/request/__init__.py
index 8f00c20b7..7672dec00 100644
--- a/scrapy/http/request/__init__.py
+++ b/scrapy/http/request/__init__.py
@@ -126,10 +126,10 @@ class Request(object_ref):
__repr__ = __str__
- def copy(self) -> RequestTypeVar:
+ def copy(self) -> "Request":
return self.replace()
- def replace(self, *args, **kwargs) -> RequestTypeVar:
+ def replace(self, *args, **kwargs) -> "Request":
"""Create a new Request with the same attributes except for those given new values"""
for x in self.attributes:
kwargs.setdefault(x, getattr(self, x))
diff --git a/scrapy/http/request/json_request.py b/scrapy/http/request/json_request.py
index dba3c3a82..728a2a104 100644
--- a/scrapy/http/request/json_request.py
+++ b/scrapy/http/request/json_request.py
@@ -10,7 +10,7 @@ import json
import warnings
from typing import Optional, Tuple
-from scrapy.http.request import Request, RequestTypeVar
+from scrapy.http.request import Request
from scrapy.utils.deprecate import create_deprecated_class
@@ -42,7 +42,7 @@ class JsonRequest(Request):
def dumps_kwargs(self) -> dict:
return self._dumps_kwargs
- def replace(self, *args, **kwargs) -> RequestTypeVar:
+ def replace(self, *args, **kwargs) -> Request:
body_passed = kwargs.get('body', None) is not None
data = kwargs.pop('data', None)
data_passed = data is not None