mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-03 19:56:54 +00:00
introduce pyupgrade, run it in python2-compatible mode
This commit is contained in:
parent
1d5dd156ab
commit
55f29c636f
7 changed files with 14 additions and 7 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue