Open piotrm0 opened 2 years ago
Note that the problem does not occur if the first line is just the triple quotes.
Ok yeah there are a couple of things going wrong here
This was caused (in part) by the change in v1.16 where Python docstrings are now parsed as rST. The problem is rST is indent sensitive and so it sees the 1st & 2nd lines in your example as separate paragraphs.
It's gonna take me a little while to fix. Workarounds until then are:
""" Text text
more text but at the same indent
Following paragraphs can be indented at this level
Or at this level if you prefer."""
Chiming in for this issue. I know it's been mentioned it would take some time, but I'd like to add some extra context.
def get_message_id(self) -> int:
"""Increments the message ID, returns old value. Use in conjunction of sending messages, to always get a unique message ID
Returns:
int: The old message ID
"""
Will, as the OP describes, rewrap into
def get_message_id(self) -> int:
"""Increments the message ID, returns old value. Use in conjunction of
"""sending messages, to always get a unique message ID
Returns:
int: The old message ID
"""
def get_message_id(self) -> int:
"""Increments the message ID, returns old value. Use in conjunction of
"""sending messages, to always get a unique message ID
Returns:
int: The old message ID
"""
The suggested workaround of changing the indentation of the Docstring to def get_message_id(self) -> int: """ Increments the message ID, returns old value. Use in conjunction of sending messages, to always get a unique message ID
Returns:
int: The old message ID"""
still incorrectly rewraps the docstring, keeps the indentation, but also squishes following lines (as expected based on the documentation)
```python
def get_message_id(self) -> int:
""" Increments the message ID, returns old value. Use in conjunction of
""" sending messages, to always get a unique message ID
Returns: int: The old message ID"""
As a sidenote: When using a formatter such as Black, the docstring will be auto-reformated to the one towards the top of this message, to match the PEP recommendations.
love the extension! just wanted to bump this issue -- currently i have to manually reformat the first line of every python docstring, and it would be super cool if the extension could handle this part automatically too :grinning:
Hi, see various python docstring formatting issues but not this one. A line like the below:
gets rewrapped into:
Notice that additional triple quotes on the second line. The result isn't even a valid string.