Skip to content

Commit c4dc936

Browse files
authored
fix skip comments when aligning variables (#58)
1 parent 5639a06 commit c4dc936

File tree

5 files changed

+29
-2
lines changed

5 files changed

+29
-2
lines changed

robotidy/transformers/AlignVariablesSection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class AlignVariablesSection(ModelTransformer):
3535
def visit_VariableSection(self, node): # noqa
3636
statements = []
3737
for child in node.body:
38-
if child.type == 'EOL':
38+
if child.type in (Token.EOL, Token.COMMENT):
3939
statements.append(child)
4040
else:
4141
statements.append(list(self.tokens_by_lines(child)))

robotidy/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.1.0'
1+
__version__ = '1.1.1'
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*** Variables ***
2+
# some comment that is longer than usual and can go and go and ends here
3+
4+
${VARIABLE 1} 10 # comment
5+
@{LIST} a b c d
6+
${LONGER_NAME_THAT_GOES_AND_GOES} longer value that goes and goes
7+
8+
&{MULTILINE} a=b
9+
... b=c
10+
... d=1
11+
${invalid}
12+
${invalid_more}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*** Variables ***
2+
# some comment that is longer than usual and can go and go and ends here
3+
4+
${VARIABLE 1} 10 # comment
5+
@{LIST} a b c d
6+
${LONGER_NAME_THAT_GOES_AND_GOES} longer value that goes and goes
7+
8+
&{MULTILINE} a=b
9+
... b=c
10+
... d=1
11+
${invalid}
12+
${invalid_more}

tests/atest/transformers/test_transformers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,3 +296,6 @@ def test_align_variables(self):
296296

297297
def test_align_with_optional_equal_signs(self):
298298
run_tidy_and_compare(self.TRANSFORMER_NAME, sources=['optional_equal_sign.robot'])
299+
300+
def test_align_with_long_comment(self):
301+
run_tidy_and_compare(self.TRANSFORMER_NAME, sources=['long_comment.robot'])

0 commit comments

Comments
 (0)