Skip to content

Commit

Permalink
comments-indentation: Refactor to use 'max' builtin
Browse files Browse the repository at this point in the history
It is unnecessary to use an `if` statement to check the maximum of two
values and then assign the value to a name. You can use the max
built-in do do this. It is straightforward and more readable.
  • Loading branch information
DimitriPapadopoulos authored and adrienverge committed Oct 7, 2022
1 parent 19d0080 commit e0f749b
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions yamllint/rules/comments_indentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ def check(conf, comment):
# # comment
# - 1
# - 2
if prev_line_indent <= next_line_indent:
prev_line_indent = next_line_indent
prev_line_indent = max(prev_line_indent, next_line_indent)

# If two indents are valid but a previous comment went back to normal
# indent, for the next ones to do the same. In other words, avoid this:
Expand Down

0 comments on commit e0f749b

Please sign in to comment.