Skip to content

changing dunder-str to dunder-repr #5150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 23, 2022
Merged

Conversation

gustavo-bordin
Copy link
Contributor

@gustavo-bordin gustavo-bordin commented May 16, 2021

What:

Changing all dunder-str to dunder-repr

Why:

Some __repr__ were being set as __repr__ = __str__, we actually dont need this because if the compiler does not find __str__, then it will get __repr__ as an alternative.

Proof:

https://onecompiler.com/python/3wxqqch57

@codecov
Copy link

codecov bot commented May 17, 2021

Codecov Report

Merging #5150 (c3b1700) into master (d7deba7) will increase coverage by 4.73%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #5150      +/-   ##
==========================================
+ Coverage   84.16%   88.90%   +4.73%     
==========================================
  Files         162      162              
  Lines       10524    10964     +440     
  Branches     1522     1799     +277     
==========================================
+ Hits         8858     9747     +889     
+ Misses       1406      936     -470     
- Partials      260      281      +21     
Impacted Files Coverage Δ
scrapy/spiders/__init__.py 100.00% <ø> (ø)
scrapy/core/http2/stream.py 91.32% <100.00%> (+64.31%) ⬆️
scrapy/http/request/__init__.py 97.77% <100.00%> (ø)
scrapy/http/response/__init__.py 97.43% <100.00%> (+0.03%) ⬆️
scrapy/settings/__init__.py 93.40% <100.00%> (+0.42%) ⬆️
scrapy/__main__.py 0.00% <0.00%> (-33.34%) ⬇️
scrapy/dupefilters.py 86.07% <0.00%> (-12.29%) ⬇️
scrapy/utils/decorators.py 75.00% <0.00%> (-7.15%) ⬇️
scrapy/downloadermiddlewares/httpproxy.py 96.61% <0.00%> (-3.39%) ⬇️
scrapy/http/cookies.py 88.88% <0.00%> (-2.71%) ⬇️
... and 75 more

@@ -151,11 +151,9 @@ def _cancel(_) -> None:

self._deferred_response = Deferred(_cancel)

def __str__(self) -> str:
def __repr__(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the typing be added here too?

@@ -121,11 +121,9 @@ def _set_body(self, body: Optional[Union[str, bytes]]) -> None:
def encoding(self) -> str:
return self._encoding

def __str__(self) -> str:
def __repr__(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the typing be added here too?

@wRAR wRAR closed this Jul 26, 2021
@wRAR wRAR reopened this Jul 26, 2021
@wRAR wRAR merged commit 45c2bd7 into scrapy:master Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants