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.

async/await keywords not recognized in code block?

See original GitHub issue

Hi,

My documentation looks like this:

.. code-block:: python

    async with aiohttp.ClientSession() as session:
        gh = GitHubAPI(session, "mariatta", oauth_token=os.getenv("GH_AUTH"))

When I run blacken-docs, I’m getting this error:

code block parse error Cannot parse: 1:6: async with aiohttp.ClientSession() as session:

But when I removed the async keyword, it works:

.. code-block:: python

    with aiohttp.ClientSession() as session:
        gh = GitHubAPI(session, "mariatta", oauth_token=os.getenv("GH_AUTH"))

Same problem when I have this type of code block:

.. code-block:: python

    await gh.patch(url, data={"state": "closed"})

Removing the await keyword works. Any idea?

Thanks.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
asottilecommented, Jun 6, 2018

Since there’s not terribly much that can be done from the blacken-docs side I’m going to close this with a sad wontfix. Thanks again for the issue 😃

0reactions
Mariattacommented, Jun 6, 2018

Thanks 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

async/await keywords not recognized in code block? #1 - GitHub
Hi, My documentation looks like this: .. code-block:: python async with aiohttp.ClientSession() as session: gh = GitHubAPI(session, ...
Read more >
.net - C# async and await keywords not working as expected ...
When the compiler encounters await keyword it will automatically schedule a task in task scheduler. The operation waits (in a non-blocking ...
Read more >
async - C# Reference - Microsoft Learn
The async keyword is contextual in that it's a keyword only when it modifies a method, a lambda expression, or an anonymous method....
Read more >
async function - JavaScript - MDN Web Docs - Mozilla
Use of async and await enables the use of ordinary try / catch blocks around asynchronous code. Note: The await keyword is only...
Read more >
Async and Await | The Odin Project
The async keyword is what lets the JavaScript engine know that you are declaring an asynchronous function. This is required to use await...
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