question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ShopifyResource.find does not propagate kwargs to PaginatedCollection

See original GitHub issue

Hey folks, I’m testing the new pagination and I’ve found that resource.find(no_iter_next=True) doesn’t work as expected (e.g. the resulting iterator will still fetch additional pages).

After having a quick look through the source code, it appears that this is because the kwargs are never passed through: https://github.com/Shopify/shopify_python_api/blob/master/shopify/base.py#L213

Overriding the variable on the collection works fine, but is non-ideal:

        collection = resource.find(**kwargs)
        collection._no_iter_next = True

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
UnicycleJonathancommented, Feb 9, 2020

It’s important that no_iter_next be the default behavior here, and only allow automatic iteration of subsequent pages if the caller has explicitly asked for that via a parameter. Otherwise, this isn’t backwards compatible and will likely introduce a lot of serious bugs and runaway code for people who are upgrading.

As mentioned above, existing code that does implicit iteration via for order in shopify.Order.find(limit=5): is expecting to iterate over at most 5 orders, but with the new behavior this will iterate over all orders in the entire shop.

This will likely break almost every Python client so it’s important to invert the default behavior.

0reactions
tanemacommented, Feb 11, 2020

Okay, I have changed my Pr to make no_iter_next to default to True. I will release this tonight so that you can use this and it will be easier to use. I will be a breaking release in case anyone has built on top of the current behaviour

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - Inheritance best practice : *args, **kwargs or explicitly ...
Update : In this case, having the *args can cause troubles if a new positional argument is added to the parent. I would...
Read more >
How To Use *args and **kwargs in Python 3 - DigitalOcean
In this tutorial, we will cover the syntax of working with *args and **kwargs as parameters within functions to pass a variable number...
Read more >
Python args and kwargs: Demystified
In this step-by-step tutorial, you'll learn how to use args and kwargs in Python to add ... If you try to execute this...
Read more >
Super Inherit Your Python Class - E.Y. - Medium
Even if Sneaky class don't need to get anything from the inheritance (no args taken), it still need to do super in order...
Read more >
Subclassing and Inheritance — PythonCert 5.0 documentation
In object-oriented programming (OOP), inheritance is a way to reuse the code of ... will get the new value, even if the methods...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found