Skip to content

Commit 3076b7c

Browse files
committed
fix: treat ellipses as code line
1 parent 62f0712 commit 3076b7c

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/docformatter/classify.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def is_code_line(token: tokenize.TokenInfo) -> bool:
266266
bool
267267
True if the token is a code line, False otherwise.
268268
"""
269-
if token.type == tokenize.NAME and not (
269+
if (token.type == tokenize.NAME or token.string == "...") and not (
270270
token.line.strip().startswith("def ")
271271
or token.line.strip().startswith("async ")
272272
or token.line.strip().startswith("class ")

tests/_data/string_files/do_format_code.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,3 +1191,25 @@ expected='''class Foo:
11911191
class Bar:
11921192
"""Bar class."""
11931193
'''
1194+
1195+
[ellipses_is_code_line]
1196+
source='''class Foo:
1197+
def bar() -> str:
1198+
"""Bar."""
1199+
1200+
...
1201+
1202+
def baz() -> None:
1203+
"""Baz."""
1204+
1205+
...
1206+
'''
1207+
expected='''class Foo:
1208+
def bar() -> str:
1209+
"""Bar."""
1210+
...
1211+
1212+
def baz() -> None:
1213+
"""Baz."""
1214+
...
1215+
'''

tests/formatter/test_do_format_code.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
("issue_243", NO_ARGS),
138138
("two_lines_between_stub_classes", NO_ARGS),
139139
("two_lines_between_stub_classes_with_preceding_comment", NO_ARGS),
140+
("ellipses_is_code_line", NO_ARGS),
140141
],
141142
)
142143
def test_do_format_code(test_key, test_args, args):

0 commit comments

Comments
 (0)