Repository navigation
Closed
Labels
C: preview styleIssues with the preview and unstable style. Add the name of the responsible feature in the title.Issues with the preview and unstable style. Add the name of the responsible feature in the title.F: docstringsHow we format docstringsHow we format docstringsT: bugSomething isn't workingSomething isn't working
Description
def x():
"""first line----------------------------------------------------------------------
second line----------------------------------------------------------------------"""Crashes with Black 22.12.0:
% black --preview --diff tests/data/preview/docstring_preview.py -l 6
error: cannot format tests/data/preview/docstring_preview.py: INTERNAL ERROR: Black produced different code on the second pass of the formatter. Please report a bug on https://github.com/psf/black/issues. This diff might be helpful: /var/folders/3b/k964cnv10097wzj3h7w07fww0000gp/T/blk_la0pkiyv.log
Oh no! π₯ π π₯
1 file would fail to reformat.
% cat /var/folders/3b/k964cnv10097wzj3h7w07fww0000gp/T/blk_la0pkiyv.log
Mode(target_versions={<TargetVersion.PY38: 8>, <TargetVersion.PY37: 7>}, line_length=6, string_normalization=True, is_pyi=False, is_ipynb=False, skip_source_first_line=False, magic_trailing_comma=True, experimental_string_processing=False, python_cell_magics=set(), preview=True)
--- source
+++ first pass
@@ -1,4 +1,6 @@
def x():
"""first line----------------------------------------------------------------------
- second line----------------------------------------------------------------------"""
+ second line----------------------------------------------------------------------
+
+ """
--- first pass
+++ second pass
@@ -1,6 +1,7 @@
def x():
"""first line----------------------------------------------------------------------
second line----------------------------------------------------------------------
+
"""
I guess this stops crashing at line-length 7 because then """ (one level of indent plus trailing quotes) fits in a line.
Metadata
Metadata
Assignees
Labels
C: preview styleIssues with the preview and unstable style. Add the name of the responsible feature in the title.Issues with the preview and unstable style. Add the name of the responsible feature in the title.F: docstringsHow we format docstringsHow we format docstringsT: bugSomething isn't workingSomething isn't working
Activity
JelleZijlstra commentedon Dec 10, 2022
Actually doesn't need long lines, this crashes in the same way with
--preview -l 6:[-]Crash with line-length 6 and long line in docstring[/-][+]Crash with line-length 6 and multi-line docstring[/+]JelleZijlstra commentedon Dec 19, 2022
This is fixed in 23.1a1, probably by d48f8ed (which I should put in a separate PR).