Open MatthewSilverstein opened 4 years ago
Hey, Matt...this is definitely a bug and not the intended behaviour. PR to fix is welcome!
On Thu, Mar 12, 2020 at 6:33 PM Matthew Silverstein < notifications@github.com> wrote:
Hey,
The list_cards_iter doesn't work on second/multiple iterations because by default the query parameter is using the previous query value. The workaround is to just initialize the query parameter on each call. I'm just wondering if there's a reason for this or if it's a bug.
Here is some sample code where the list should be iterated twice: for card in card_list.list_cards_iter(card_filter='all'): print(card.name) for card in card_list.list_cards_iter(card_filter='all'): print(card.name)
Here is the workaround for actually iterating twice: for card in card_list.list_cards_iter(card_filter='all', query={}): print( card.name) for card in card_list.list_cards_iter(card_filter='all', query={}): print(card.name)
The fix is to change the query parameter to None instead of an empty dictionary: https://docs.quantifiedcode.com/python-anti-patterns/correctness/mutable_default_value_as_argument.html
Thanks, Matt
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sarumont/py-trello/issues/307, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABNGYMDRKPUCFM7EHUYOXTRHF5OXANCNFSM4LGYCUZQ .
Hey,
The list_cards_iter doesn't work on second/multiple iterations because by default the query parameter is using the previous query value. The workaround is to just initialize the query parameter on each call. I'm just wondering if there's a reason for this or if it's a bug.
Here is some sample code where the list should be iterated twice:
Here is the workaround for actually iterating twice:
The fix is to change the query parameter to None instead of an empty dictionary: https://docs.quantifiedcode.com/python-anti-patterns/correctness/mutable_default_value_as_argument.html
Thanks, Matt