From 629398c37f456f3a9ba2197b53a2688c677275e6 Mon Sep 17 00:00:00 2001 From: monosans Date: Fri, 16 Jul 2021 11:14:13 +0300 Subject: [PATCH] Replace comparisons with min/max --- src/flake8/__init__.py | 4 +--- src/flake8/checker.py | 3 +-- src/flake8/processor.py | 3 +-- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/flake8/__init__.py b/src/flake8/__init__.py index 57a8ed3..b7c8dae 100644 --- a/src/flake8/__init__.py +++ b/src/flake8/__init__.py @@ -53,9 +53,7 @@ def configure_logging(verbosity, filename=None, logformat=LOG_FORMAT): """ if verbosity <= 0: return - if verbosity > 3: - verbosity = 3 - + verbosity = min(verbosity, 3) log_level = _VERBOSITY_TO_LOG_LEVEL[verbosity] if not filename or filename in ("stderr", "stdout"): diff --git a/src/flake8/checker.py b/src/flake8/checker.py index 7130df3..2c964d7 100644 --- a/src/flake8/checker.py +++ b/src/flake8/checker.py @@ -464,8 +464,7 @@ class FileChecker: row_offset = len(lines) - 1 logical_line = lines[0] logical_line_length = len(logical_line) - if column > logical_line_length: - column = logical_line_length + column = min(column, logical_line_length) row -= row_offset column -= column_offset return row, column diff --git a/src/flake8/processor.py b/src/flake8/processor.py index 6b7d3c4..bc9e275 100644 --- a/src/flake8/processor.py +++ b/src/flake8/processor.py @@ -160,8 +160,7 @@ class FileProcessor: (start_row, start_col) = mapping[0][1] start_line = self.lines[start_row - 1] self.indent_level = expand_indent(start_line[:start_col]) - if self.blank_before < self.blank_lines: - self.blank_before = self.blank_lines + self.blank_before = max(self.blank_before, self.blank_lines) def update_checker_state_for(self, plugin: Dict[str, Any]) -> None: """Update the checker_state attribute for the plugin."""