Skip to content
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

Type annotations #172

Merged
merged 18 commits into from
Aug 24, 2021
Merged

Type annotations #172

merged 18 commits into from
Aug 24, 2021

Conversation

lucywang000
Copy link
Member

@lucywang000 lucywang000 commented Jun 9, 2021

A new attempt after #123 .

The generated document now has type hints included as well:

Screen Shot 2021-08-09 at 3 10 24 PM

@codecov
Copy link

codecov bot commented Jun 9, 2021

Codecov Report

Merging #172 (a1c102c) into master (bb9acd8) will increase coverage by 0.98%.
The diff coverage is 99.09%.

❗ Current head a1c102c differs from pull request most recent head 9fcbe13. Consider uploading reports for the commit 9fcbe13 to get more accurate results

@@            Coverage Diff             @@
##           master     #172      +/-   ##
==========================================
+ Coverage   94.70%   95.68%   +0.98%     
==========================================
  Files           6        7       +1     
  Lines         434      464      +30     
  Branches       88       88              
==========================================
+ Hits          411      444      +33     
+ Misses         12       10       -2     
+ Partials       11       10       -1     
Impacted Files Coverage Δ
w3lib/encoding.py 98.68% <93.75%> (+0.15%) ⬆️
w3lib/_types.py 100.00% <100.00%> (ø)
w3lib/html.py 95.45% <100.00%> (+0.12%) ⬆️
w3lib/http.py 100.00% <100.00%> (+3.12%) ⬆️
w3lib/url.py 98.02% <100.00%> (+0.12%) ⬆️
w3lib/util.py 72.22% <100.00%> (+7.51%) ⬆️

@lucywang000 lucywang000 force-pushed the add-type-annotations branch 2 times, most recently from c687b34 to ba6f231 Compare August 2, 2021 06:24
@lucywang000 lucywang000 force-pushed the add-type-annotations branch 2 times, most recently from 1a89acb to 2af9b30 Compare August 9, 2021 06:33
@lucywang000 lucywang000 force-pushed the add-type-annotations branch 2 times, most recently from 16ec75f to 7c03de7 Compare August 9, 2021 06:43
@lucywang000 lucywang000 force-pushed the add-type-annotations branch from 7c03de7 to 1a81a47 Compare August 9, 2021 07:05
@lucywang000
Copy link
Member Author

@Gallaecio I think this patch is ready for a review :)

auth = auth.encode(encoding)
return b"Basic " + urlsafe_b64encode(auth)
auth = "%s:%s" % (to_native_str(username), to_native_str(password))
# XXX: RFC 2617 doesn't define encoding, but ISO-8859-1
Copy link
Member

Choose a reason for hiding this comment

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

is this comment still needed? I think it was about the encode call which is no longer done?

Copy link
Member

Choose a reason for hiding this comment

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

I think it applies as long as we accept an encoding parameter here with that default value. We are still using the encoding, only now it has moved to the to_bytes call below.

run-mypy.sh Outdated Show resolved Hide resolved
auth = auth.encode(encoding)
return b"Basic " + urlsafe_b64encode(auth)
auth = "%s:%s" % (to_native_str(username), to_native_str(password))
# XXX: RFC 2617 doesn't define encoding, but ISO-8859-1
Copy link
Member

Choose a reason for hiding this comment

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

I think it applies as long as we accept an encoding parameter here with that default value. We are still using the encoding, only now it has moved to the to_bytes call below.

w3lib/url.py Outdated Show resolved Hide resolved
w3lib/url.py Outdated Show resolved Hide resolved
w3lib/util.py Outdated Show resolved Hide resolved
lucywang000 and others added 2 commits August 23, 2021 11:29
Co-authored-by: Adrián Chaves <adrian@chaves.io>
@lucywang000
Copy link
Member Author

@wRAR @Gallaecio Thanks for your review comments. I have addressed all your feedback.

docs/w3lib.rst Outdated Show resolved Hide resolved
Improve ParseDataURIResult documentation
@lucywang000
Copy link
Member Author

@Gallaecio I've merged your fix and made some changes to make the CI pass.

@lucywang000
Copy link
Member Author

@Gallaecio anything else I need to do to make this merged?

@Gallaecio
Copy link
Member

Gallaecio commented Aug 24, 2021

I don’t think so. I’m not merging myself yet just in case @wRAR wants a final look first.

Copy link
Member

@wRAR wRAR left a comment

Choose a reason for hiding this comment

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

Thank you!

@wRAR wRAR merged commit 101d438 into scrapy:master Aug 24, 2021
@lucywang000 lucywang000 deleted the add-type-annotations branch August 24, 2021 11:12
@lucywang000
Copy link
Member Author

Thanks guys!

@kmike kmike added this to the 2.0.0 milestone Aug 8, 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.

4 participants