Git Product home page Git Product logo

Comments (9)

rbw avatar rbw commented on August 27, 2024

Hello,

I've created a branch with a fix for this in in 96aaccd
I'd appreciate if you could test it, also, see if the issue with double dicts is gone (couldn't reproduce this).

Thanks

/Robert

from pysnow.

siddweiker avatar siddweiker commented on August 27, 2024

Hey Robert,

I don't think that is the intended functionality. I would expect that when iterating over an empty result that it should behave similar to an empty list.
When I change that line 95 in resource.py to pass it seems to behave as such, but I'm not sure if that is the correct solution.

from pysnow.

rbw avatar rbw commented on August 27, 2024

Not that it makes a big difference in this particular scenario, but raising StopIteration here actually signals that there are no further values, which should make it behave just like an empty list.. just like pass or removing the empty result test altogether.

Some tests using StopIteration (same results as pass or removing the empty-test):

# convert generator object to list
>>> print(list(response.all()))
[]

# convert to list and check length
>>> print(len(list(response.all())))
0

# list comprehension
>>> print([r for r in response.all()])
[]

If we want a list containing an empty dictionary here then raising StopIteration is definitely the right way to go imo.. however, I don't think that's what we want.

So, the best solution here is probably to remove the test altogether. Or what do you think?

from pysnow.

siddweiker avatar siddweiker commented on August 27, 2024

Oh, maybe I did not test against the StopIteration version properly. Sorry about that. If it behaves like your code then that is perfect.

from pysnow.

rbw avatar rbw commented on August 27, 2024

All right, I'll fix this later today.

from pysnow.

siddweiker avatar siddweiker commented on August 27, 2024

I properly tested this commit, and it fixes the issue. Thanks again.

from pysnow.

rbw avatar rbw commented on August 27, 2024

Fixed. The new version is available on pypi.

from pysnow.

siddweiker avatar siddweiker commented on August 27, 2024

Quick addendum to this; based on PEP 479 the StopIteration is deprecated in python 3.5 in favor of return. The error I received before was actually a warning, apologies for the confusion.

DeprecationWarning: generator 'Response._parse_response' raised StopIteration

from pysnow.

rbw avatar rbw commented on August 27, 2024

@siddweiker Ah, yes.. you're right. Simply using return (without a value) should be compatible with both python 2 and 3.

I'll have this fixed in the next version.

Thanks :)

from pysnow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.