From e0f749bf5da8c3f9f3ba1dbf0a3ec237d9d624b1 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 17 Jul 2022 08:53:34 +0200 Subject: [PATCH] comments-indentation: Refactor to use 'max' builtin 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. --- yamllint/rules/comments_indentation.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/yamllint/rules/comments_indentation.py b/yamllint/rules/comments_indentation.py index c5e6f88..569abee 100644 --- a/yamllint/rules/comments_indentation.py +++ b/yamllint/rules/comments_indentation.py @@ -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: