Skip to content

update iter() for better fallback in getting 'meta' argument #146

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

Conversation

BurnzZ
Copy link
Contributor

@BurnzZ BurnzZ commented Jan 31, 2020

Fixes #145

Here's a condensed version of the code to verify the issue and fix:

def iter(**apiparams):
    print(apiparams)
    drop_key = '_key' not in apiparams.get('meta', [])
    print(drop_key)

def iter_fixed(**apiparams):
    print(apiparams)	
    drop_key = '_key' not in (apiparams.get('meta') or [])
    print(drop_key)


>>> iter(meta=None)
{'meta': None}
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 3, in iter
TypeError: argument of type 'NoneType' is not iterable

>>> iter_fixed(meta=None)
{'meta': None}
True

>>> iter_fixed()
{}
True

@BurnzZ BurnzZ requested a review from vshlapakov January 31, 2020 04:36
@codecov
Copy link

codecov bot commented Jan 31, 2020

Codecov Report

Merging #146 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #146   +/-   ##
=======================================
  Coverage   93.96%   93.96%           
=======================================
  Files          28       28           
  Lines        1938     1938           
=======================================
  Hits         1821     1821           
  Misses        117      117
Impacted Files Coverage Δ
scrapinghub/client/proxy.py 95.71% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ef7c41a...fa4d0b0. Read the comment docs.

Copy link
Contributor

@vshlapakov vshlapakov left a comment

Choose a reason for hiding this comment

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

Accidentally spot an uncovered review request, sorry for that. It looks good, though I'm not a maintainer of the lib anymore, not sure if you need an approval from someone else on the subject.

@rafaelcapucho
Copy link
Contributor

@vshlapakov Hey!, thank you Vik ✌

@rafaelcapucho rafaelcapucho merged commit d30aced into scrapinghub:master Jul 26, 2021
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.

iter() not handling meta=None gracefully
3 participants