diff options
| author | Anthony Sottile <asottile@umich.edu> | 2021-03-29 17:23:34 -0700 |
|---|---|---|
| committer | Anthony Sottile <asottile@umich.edu> | 2021-03-29 20:21:36 -0700 |
| commit | 55f29c636f8eb80ec6544169c59ff3ab7733d1a1 (patch) | |
| tree | e4ec70b3617c62970ab9dd94e7798147b1a46ae5 | |
| parent | 1d5dd156ab9f2e37e40f95eb15c5a2c2cd49a7a9 (diff) | |
| download | flake8-55f29c636f8eb80ec6544169c59ff3ab7733d1a1.tar.gz | |
introduce pyupgrade, run it in python2-compatible mode
| -rw-r--r-- | .pre-commit-config.yaml | 4 | ||||
| -rw-r--r-- | src/flake8/checker.py | 7 | ||||
| -rw-r--r-- | src/flake8/exceptions.py | 2 | ||||
| -rw-r--r-- | src/flake8/plugins/manager.py | 2 | ||||
| -rw-r--r-- | src/flake8/processor.py | 2 | ||||
| -rw-r--r-- | src/flake8/utils.py | 2 | ||||
| -rw-r--r-- | tests/unit/test_file_processor.py | 2 |
7 files changed, 14 insertions, 7 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e1b34f3..4db0949 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,6 +13,10 @@ repos: - id: black args: [--line-length=78] files: ^src/ +- repo: https://github.com/asottile/pyupgrade + rev: v2.11.0 + hooks: + - id: pyupgrade - repo: https://github.com/pre-commit/mirrors-mypy rev: v0.720 hooks: diff --git a/src/flake8/checker.py b/src/flake8/checker.py index 224bf64..82ce090 100644 --- a/src/flake8/checker.py +++ b/src/flake8/checker.py @@ -388,7 +388,7 @@ class FileChecker(object): # NOTE(sigmavirus24): Historically, pep8 has always reported this # as an E902. We probably *want* a better error code for this # going forward. - message = "{0}: {1}".format(type(e).__name__, e) + message = "{}: {}".format(type(e).__name__, e) self.report("E902", 0, 0, message) return None @@ -476,7 +476,10 @@ class FileChecker(object): except (ValueError, SyntaxError, TypeError) as e: row, column = self._extract_syntax_information(e) self.report( - "E999", row, column, "%s: %s" % (type(e).__name__, e.args[0]) + "E999", + row, + column, + "{}: {}".format(type(e).__name__, e.args[0]), ) return diff --git a/src/flake8/exceptions.py b/src/flake8/exceptions.py index ea9bc98..e1b0539 100644 --- a/src/flake8/exceptions.py +++ b/src/flake8/exceptions.py @@ -40,7 +40,7 @@ class InvalidSyntax(Flake8Exception): def __init__(self, exception): # type: (Exception) -> None """Initialize our InvalidSyntax exception.""" self.original_exception = exception - self.error_message = "{0}: {1}".format( + self.error_message = "{}: {}".format( exception.__class__.__name__, exception.args[0] ) self.error_code = "E902" diff --git a/src/flake8/plugins/manager.py b/src/flake8/plugins/manager.py index abfd14b..4f482dd 100644 --- a/src/flake8/plugins/manager.py +++ b/src/flake8/plugins/manager.py @@ -40,7 +40,7 @@ class Plugin(object): def __repr__(self): # type: () -> str """Provide an easy to read description of the current plugin.""" - return 'Plugin(name="{0}", entry_point="{1}")'.format( + return 'Plugin(name="{}", entry_point="{}")'.format( self.name, self.entry_point.value ) diff --git a/src/flake8/processor.py b/src/flake8/processor.py index ad011c3..8ace9a3 100644 --- a/src/flake8/processor.py +++ b/src/flake8/processor.py @@ -446,7 +446,7 @@ def count_parentheses(current_parentheses_count, token_text): def log_token(log, token): # type: (logging.Logger, _Token) -> None """Log a token to a provided logging object.""" if token[2][0] == token[3][0]: - pos = "[%s:%s]" % (token[2][1] or "", token[3][1]) + pos = "[{}:{}]".format(token[2][1] or "", token[3][1]) else: pos = "l.%s" % token[3][0] log.log( diff --git a/src/flake8/utils.py b/src/flake8/utils.py index 29dc554..893571e 100644 --- a/src/flake8/utils.py +++ b/src/flake8/utils.py @@ -470,7 +470,7 @@ def get_python_version(): # type: () -> str :rtype: str """ - return "%s %s on %s" % ( + return "{} {} on {}".format( platform.python_implementation(), platform.python_version(), platform.system(), diff --git a/tests/unit/test_file_processor.py b/tests/unit/test_file_processor.py index 0215ddf..b72e064 100644 --- a/tests/unit/test_file_processor.py +++ b/tests/unit/test_file_processor.py @@ -130,7 +130,7 @@ def test_noqa_line_for(default_options): ]) for i in range(1, 4): - assert file_processor.noqa_line_for(i) == 'Line {0}\n'.format(i) + assert file_processor.noqa_line_for(i) == 'Line {}\n'.format(i) def test_noqa_line_for_continuation(default_options): |
