-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
[MRG+1] Allow dropping field in from_response formdata #2721
[MRG+1] Allow dropping field in from_response formdata #2721
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2721 +/- ##
=======================================
Coverage 84.75% 84.75%
=======================================
Files 162 162
Lines 9155 9155
Branches 1358 1359 +1
=======================================
Hits 7759 7759
Misses 1145 1145
Partials 251 251
Continue to review full report at Codecov.
|
scrapy/http/request/form.py
Outdated
@@ -135,7 +135,7 @@ def _get_inputs(form, formdata, dont_click, clickdata, response): | |||
if clickable and clickable[0] not in formdata and not clickable[0] is None: | |||
values.append(clickable) | |||
|
|||
values.extend(formdata.items()) | |||
values.extend([(k, v) for k, v in formdata.items() if v is not None]) |
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.
no need to build an intermediate list. Just use:
values.extend((k, v) for k, v in formdata.items() if v is not None)
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 didn't realize you could do that. Thanks! Would you prefer if I squashed this into the other commit on this file?
Nice to have feature, simple implementation and good test case. thanks @HarrisonGregg |
Yes, please.
El lun., 15 de may. de 2017 12:28, Harrison <notifications@github.com>
escribió:
… ***@***.**** commented on this pull request.
------------------------------
In scrapy/http/request/form.py
<#2721 (comment)>:
> @@ -135,7 +135,7 @@ def _get_inputs(form, formdata, dont_click, clickdata, response):
if clickable and clickable[0] not in formdata and not clickable[0] is None:
values.append(clickable)
- values.extend(formdata.items())
+ values.extend([(k, v) for k, v in formdata.items() if v is not None])
I didn't realize you could do that. Thanks! Would you prefer if I squashed
this into the other commit on this file?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2721 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AACR-cHifvKPMXSQnRv2Ehgr68khgrpTks5r6G80gaJpZM4NMuw5>
.
|
313f157
to
ffef828
Compare
@dangra Squashed. |
@redapple I think this is ready to go. Is it still in time for 1.4.0? |
@dangra , alright, lets include it. |
Implements #667.
FormRequest.from_response
is very helpful, but sometimes it includes a field that you would like to remove. With this change, you can include a field with valueNone
informdata
when callingfrom_response
, and the field will be omitted from the body of the returned request.