Skip to content

Commit

Permalink
Changing separator between single and multiline comments to space
Browse files Browse the repository at this point in the history
  • Loading branch information
swansonk14 committed Jul 20, 2020
1 parent 6c5a3db commit 3a3e8a1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tap/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def get_class_variables(cls: type) -> OrderedDict:
if (class_variable is not None
and token['token_type'] == tokenize.STRING
and token['token'][:3] in {'"""', "'''"}):
sep = '\n\n' if variable_to_comment[class_variable]['comment'] else ''
sep = ' ' if variable_to_comment[class_variable]['comment'] else ''
variable_to_comment[class_variable]['comment'] += sep + token['token'][3:-3].strip()

# Match class variable
Expand Down
8 changes: 4 additions & 4 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def func(self):
class_variables = OrderedDict()
class_variables['arg_1'] = {'comment': 'Arg 1 comment'}
class_variables['arg_2'] = {'comment': 'Arg 2 comment'}
class_variables['arg_3'] = {'comment': 'Poorly formatted comment\n\nMore comment'}
class_variables['arg_3'] = {'comment': 'Poorly formatted comment More comment'}
self.assertEqual(get_class_variables(CommentedVariable), class_variables)

def test_bad_spacing_multiline(self):
Expand All @@ -237,7 +237,7 @@ class TrickyMultiline:
"""

class_variables = OrderedDict()
comment = 'Header line\n\nFooter\nT\n A\n P\n\n multi\n line!!'
comment = 'Header line Footer\nT\n A\n P\n\n multi\n line!!'
class_variables['foo'] = {'comment': comment}
self.assertEqual(get_class_variables(TrickyMultiline), class_variables)

Expand All @@ -254,9 +254,9 @@ def test_functions_with_docs_multiline(self):
class FunctionsWithDocs:
i: int = 0

def f():
def f(self):
"""Function"""
a: str = 0
a: str = 'hello'
"""with docs"""

class_variables = OrderedDict()
Expand Down

0 comments on commit 3a3e8a1

Please sign in to comment.