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.

v0.3.6 throws TypeError: '_GeneratorContextManager' object is not subscriptable

See original GitHub issue

Hello, v0.3.6 doesn’t seem to work anymore - example code:

from darksky import forecast
key='APIKEY'
boston = forecast(key, 42.3601, -71.0589)
boston['currently']

and then I get this traceback:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: '_GeneratorContextManager' object is not subscriptable

Downgraded to v0.3.5 and it worked again.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
lukaskubiscommented, Aug 11, 2017

I’ll revert this nonsense back to what it was during the weekend and update the whole thing. I don’t even remember what was my original intention behind this.

1reaction
lukaskubiscommented, Jul 29, 2017

AAA yes I see now, this is a change in functionality, whereby the forecast function, instead of returning Forecast object, now acts just as a context manager, yielding the Forercast inside a with statement.

try one of these: (I’m unable to do so at this time):

from darksky import forecast
key='APIKEY'
with forecast(key, 42.3601, -71.0589) as boston:
    boston['currently']
from darksky import forecast
key='APIKEY'
boston = Forecast(key, 42.3601, -71.0589)
boston['currently']

I’ll keep this issue open until I do something about this. Thanks for letting me know.

Read more comments on GitHub >

github_iconTop Results From Across the Web

'GeneratorContextManager' Object does not support indexing
It is a @contextmanager, which handles the temporary file deletion for you. But one should use it with with : with pfx_to_pem(clientCert ...
Read more >
contextlib — Utilities for with-statement contexts ... - Python Docs
An abstract base class for classes that implement object. ... New in version 3.6. ... Otherwise the generator context manager will indicate to...
Read more >
Context Managers and Python's with Statement
In this step-by-step tutorial, you'll learn what the Python with statement is and how to use it with existing context managers.
Read more >
contextmanager function return value incorrectly marked as ...
from contextlib import contextmanager @contextmanager def mycm(): yield @mycm() # <-- PyCharm flags as 'Generator' object is not callable def ...
Read more >
The Curious Case of Python's Context Manager
If no unhandled exception occurs, the code gracefully proceeds to the finally ... from contextlib import contextmanager @contextmanager def ...
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