Replace return type

This commit is contained in:
Eugenio Lacuesta 2021-06-07 13:25:04 -03:00
parent 479260dca0
commit ce6447731a
No known key found for this signature in database
GPG Key ID: DA3EF2D0913E9810
2 changed files with 4 additions and 4 deletions

View File

@ -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))

View File

@ -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