Skip to content

Commit

Permalink
better typing
Browse files Browse the repository at this point in the history
  • Loading branch information
soundofspace committed Apr 2, 2024
1 parent 3149914 commit 8eabb1b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion scrapy/crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def __init__(
self.stats: Optional[StatsCollector] = None
self.logformatter: Optional[LogFormatter] = None
self.request_fingerprinter: Optional[RequestFingerprinter] = None
self.spider: Optional[Spider] = None
self.spider: Optional[S] = None
self.engine: Optional[ExecutionEngine] = None

def _update_root_log_handler(self) -> None:
Expand Down
18 changes: 16 additions & 2 deletions scrapy/http/response/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,14 @@ def _set_url(self, url: str):
f"{type(self).__name__} url must be str, " f"got {type(url).__name__}"
)

url = property(_get_url, obsolete_setter(_set_url, "url"))
@property
def url(self):
return self._get_url()

@url.setter
def url(self, value: str):
setter = obsolete_setter(self._set_url, "url")
setter(self, value)

def _get_body(self):
return self._body
Expand All @@ -108,7 +115,14 @@ def _set_body(self, body):
else:
self._body = body

body = property(_get_body, obsolete_setter(_set_body, "body"))
@property
def body(self):
return self._get_body()

@body.setter
def body(self, value: bytes):
setter = obsolete_setter(self._set_body, "body")
setter(self, value)

def __repr__(self):
return f"<{self.status} {self.url}>"
Expand Down

0 comments on commit 8eabb1b

Please sign in to comment.