Docstrings are indented when using await
See original GitHub issuecode = """
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:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
Yeah, Ithink it’s reasonable to tell users that using 3.8+ for this to work is reasonable. 3.7 is best effort.