From 5bacc4822e80a78a2a287a5d1e417c0d3b7ddbdf Mon Sep 17 00:00:00 2001 From: Gustavo Bordin Date: Sun, 16 May 2021 18:40:30 -0300 Subject: [PATCH] changing dunder-str to dunder-repr --- scrapy/core/http2/stream.py | 6 ++---- scrapy/http/request/__init__.py | 4 +--- scrapy/http/response/__init__.py | 4 +--- scrapy/settings/__init__.py | 4 +--- scrapy/spiders/__init__.py | 4 +--- 5 files changed, 6 insertions(+), 16 deletions(-) diff --git a/scrapy/core/http2/stream.py b/scrapy/core/http2/stream.py index c2a4b702f..a3a9e5e1d 100644 --- a/scrapy/core/http2/stream.py +++ b/scrapy/core/http2/stream.py @@ -150,12 +150,10 @@ class Stream: self.close(StreamCloseReason.CANCELLED) self._deferred_response = Deferred(_cancel) - - def __str__(self) -> str: + + def __repr__(self): return f'Stream(id={self.stream_id!r})' - __repr__ = __str__ - @property def _log_warnsize(self) -> bool: """Checks if we have received data which exceeds the download warnsize diff --git a/scrapy/http/request/__init__.py b/scrapy/http/request/__init__.py index ad884feac..a1857c604 100644 --- a/scrapy/http/request/__init__.py +++ b/scrapy/http/request/__init__.py @@ -109,11 +109,9 @@ class Request(object_ref): def encoding(self): return self._encoding - def __str__(self): + def __repr__(self): return f"<{self.method} {self.url}>" - __repr__ = __str__ - def copy(self): """Return a copy of this Request""" return self.replace() diff --git a/scrapy/http/response/__init__.py b/scrapy/http/response/__init__.py index 185a9bb67..eb80c5214 100644 --- a/scrapy/http/response/__init__.py +++ b/scrapy/http/response/__init__.py @@ -87,11 +87,9 @@ class Response(object_ref): body = property(_get_body, obsolete_setter(_set_body, 'body')) - def __str__(self): + def __repr__(self): return f"<{self.status} {self.url}>" - __repr__ = __str__ - def copy(self): """Return a copy of this Response""" return self.replace() diff --git a/scrapy/settings/__init__.py b/scrapy/settings/__init__.py index 1fe1e6fd1..69d0476eb 100644 --- a/scrapy/settings/__init__.py +++ b/scrapy/settings/__init__.py @@ -51,11 +51,9 @@ class SettingsAttribute: self.value = value self.priority = priority - def __str__(self): + def __repr__(self): return f"" - __repr__ = __str__ - class BaseSettings(MutableMapping): """ diff --git a/scrapy/spiders/__init__.py b/scrapy/spiders/__init__.py index c13ba4b3c..1c079ff27 100644 --- a/scrapy/spiders/__init__.py +++ b/scrapy/spiders/__init__.py @@ -106,11 +106,9 @@ class Spider(object_ref): if callable(closed): return closed(reason) - def __str__(self): + def __repr__(self): return f"<{type(self).__name__} {self.name!r} at 0x{id(self):0x}>" - __repr__ = __str__ - # Top-level imports from scrapy.spiders.crawl import CrawlSpider, Rule