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.

Docstrings are indented when using await

See original GitHub issue
code = """
import numpy as np
import matplotlib.pyplot as plt
plt.imshow(np.random.randn(10, 10))
plt.show()
"""

print(code)
await asyncio.sleep(1)

yields

        import numpy as np
        import matplotlib.pyplot as plt
        plt.imshow(np.random.randn(10, 10))
        plt.show()

with indentation (8 indents to be exact), whereas dropping the await doesn’t.

I figured this belonged here rather than in Jupyter notebook, but I’m using the notebook to run this example (I’m not sure if it would be reproducible using ipython from the CLI since I imagine the code = ... and await ... get run in different execution requests).

For now, I can just textwrap.dedent, but thought I’d file the issue nonetheless.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
Carreaucommented, Mar 25, 2019

Thanks for the ping.

I’m hopping to get some of this natively handled by CPython at some point. I’ll see if I can do something when I have some time.

0reactions
Carreaucommented, Aug 22, 2020

Yeah, Ithink it’s reasonable to tell users that using 3.8+ for this to work is reasonable. 3.7 is best effort.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does python demand that docstrings be indented?
It's just a string. Of course, it is associated with the function, but the point is it needs to be parsed according to...
Read more >
unexpected indent of test function with docstring #4066
When run test with docstring, FAILURE message indent is unexpected. For example, import unittest class TestSome(unittest.
Read more >
Python Tutorial: Docstrings - YouTube
In Google style, the docstring starts with a concise description of what ... you can break to the next line and indent as...
Read more >
Complete Guide to Python Docstring
Guide to Python Docstring. Here we discuss the basics of Docstrings in Python along with syntax and examples of different Docstrings.
Read more >
Python Style Guide
Code Meaning Suggestion E112 expected an indented block. Why: A bug ✓✓ E113 unexpected indentation. Why: A bug ✓✓ E2 Whitespace
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