scrapinghub / python-scrapinghub

A client interface for Scrapinghub's API
https://python-scrapinghub.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
202 stars 63 forks source link

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

Closed BurnzZ closed 3 years ago

BurnzZ commented 4 years ago

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
codecov[bot] commented 4 years ago

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%> (ø) :arrow_up:

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.

rafaelcapucho commented 3 years ago

@vshlapakov Hey!, thank you Vik ✌