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
docs: use __init__ method instead of constructor #4088
docs: use __init__ method instead of constructor #4088
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4088 +/- ##
==========================================
- Coverage 85.68% 83.04% -2.65%
==========================================
Files 165 165
Lines 9734 9734
Branches 1463 1463
==========================================
- Hits 8341 8084 -257
- Misses 1136 1385 +249
- Partials 257 265 +8
|
You have successfully used `` in many documentation changes, but some changes use a single ` instead, which is incorrect (it applies italics). |
9ef093a
to
ecb6cfd
Compare
ecb6cfd
to
da8cd94
Compare
thanks for the review, I hope I got it right this time |
docs/topics/loaders.rst
Outdated
@@ -265,7 +265,7 @@ There are several ways to modify Item Loader context values: | |||
loader.context['unit'] = 'cm' | |||
|
|||
2. On Item Loader instantiation (the keyword arguments of Item Loader | |||
constructor are stored in the Item Loader context):: | |||
``__init__`` methodare stored in the Item Loader context):: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
``__init__`` methodare stored in the Item Loader context):: | |
``__init__`` method are stored in the Item Loader context):: |
I’ve seen this issue in a few more replacements below, where the character right after ‘method’ (a space, a dot, a comma) was accidentally removed. Could you please take a look?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Gallaecio thanks for your patience, change pushed.
5219435
to
d21e103
Compare
Thank you for taking your time, these consistency changes can be tiresome but are important to avoid user confusion.
There’s only one more thing I would like to bring up: some comments used ‘constructor’ to refer to methods other than __init__
used to create instances (e.g. from_crawler
, from_settings
). I believe in those cases the right wording would be “factory method”.
That said, I’m OK with merging the changes as is, I believe they are a significant improvement.
tests/test_utils_misc/__init__.py
Outdated
# 1. with no alternative __init__ methods | ||
# 2. with from_settings() __init__ method | ||
# 3. with from_crawler() __init__ method | ||
# 4. with from_settings() and from_crawler() __init__ method |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think here "constructor" is replaced with __init__
incorrectly here; "constructor" here is a single word for from_crawler/from_settings/etc., not as a synonym to __init__
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so should one leave it as is "constructor" or use “factory method” instead as @Gallaecio mentioned in #4088 (review)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think so; no strong opinion about constructor/factory methods, I was always thinking about them as of "alternative constructors", so comment before the change as-is looks fine to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scrapy/extensions/feedexport.py
Outdated
@@ -106,7 +106,7 @@ def __init__(self, uri, access_key=None, secret_key=None, acl=None): | |||
warnings.warn( | |||
"Initialising `scrapy.extensions.feedexport.S3FeedStorage` " | |||
"without AWS keys is deprecated. Please supply credentials or " | |||
"use the `from_crawler()` constructor.", | |||
"use the `from_crawler()` ``__init__`` method.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should be kept as "constructor" here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when I thought I got them all... bf5c1a3
Issue scrapy#4086 Co-Authored-By: Mikhail Korobov <kmike84@gmail.com>
Resolves #4086