Fix CI by upgrading AP templates

This commit is contained in:
Anthony Sottile 2020-02-03 08:41:48 -08:00
parent 31853d6c43
commit fea76b9ea1
8 changed files with 39 additions and 34 deletions

View File

@ -13,32 +13,32 @@ repos:
- id: double-quote-string-fixer
- id: requirements-txt-fixer
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.1
rev: 3.7.9
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v1.4.3
rev: v1.5
hooks:
- id: autopep8
- repo: https://github.com/pre-commit/pre-commit
rev: v1.14.2
rev: v2.0.1
hooks:
- id: validate_manifest
- repo: https://github.com/asottile/reorder_python_imports
rev: v1.3.5
rev: v1.9.0
hooks:
- id: reorder-python-imports
language_version: python3
- repo: https://github.com/asottile/pyupgrade
rev: v1.11.1
rev: v1.26.2
hooks:
- id: pyupgrade
- repo: https://github.com/asottile/add-trailing-comma
rev: v0.7.1
rev: v1.5.0
hooks:
- id: add-trailing-comma
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.660
rev: v0.761
hooks:
- id: mypy
language_version: python3

View File

@ -10,7 +10,7 @@ resources:
type: github
endpoint: github
name: asottile/azure-pipeline-templates
ref: refs/tags/v0.0.8
ref: refs/tags/v1.0.0
jobs:
- template: job--pre-commit.yml@asottile

View File

@ -23,14 +23,15 @@ def main(argv=None): # type: (Optional[Sequence[str]]) -> int
with open(filename, 'rb') as f:
ast.parse(f.read(), filename=filename)
except SyntaxError:
print('{}: failed parsing with {} {}:'.format(
filename,
platform.python_implementation(),
sys.version.partition(' ')[0],
))
print('\n{}'.format(
' ' + traceback.format_exc().replace('\n', '\n '),
))
print(
'{}: failed parsing with {} {}:'.format(
filename,
platform.python_implementation(),
sys.version.partition(' ')[0],
),
)
tb = ' ' + traceback.format_exc().replace('\n', '\n ')
print('\n{}'.format(tb))
retval = 1
return retval

View File

@ -41,9 +41,11 @@ def main(argv=None): # type: (Optional[Sequence[str]]) -> int
for i, line in enumerate(inputfile):
for pattern in CONFLICT_PATTERNS:
if line.startswith(pattern):
print(WARNING_MSG.format(
pattern.decode(), filename, i + 1,
))
print(
WARNING_MSG.format(
pattern.decode(), filename, i + 1,
),
)
retcode = 1
return retcode

View File

@ -25,9 +25,11 @@ def has_coding(line): # type: (bytes) -> bool
)
class ExpectedContents(collections.namedtuple(
'ExpectedContents', ('shebang', 'rest', 'pragma_status', 'ending'),
)):
class ExpectedContents(
collections.namedtuple(
'ExpectedContents', ('shebang', 'rest', 'pragma_status', 'ending'),
),
):
"""
pragma_status:
- True: has exactly the coding pragma expected
@ -138,9 +140,11 @@ def main(argv=None): # type: (Optional[Sequence[str]]) -> int
)
retv |= file_ret
if file_ret:
print(fmt.format(
pragma=args.pragma.decode(), filename=filename,
))
print(
fmt.format(
pragma=args.pragma.decode(), filename=filename,
),
)
return retv

View File

@ -45,9 +45,8 @@ def fix_strings(filename): # type: (str) -> int
splitcontents = list(contents)
# Iterate in reverse so the offsets are always correct
tokens = reversed(list(tokenize.generate_tokens(
io.StringIO(contents).readline,
)))
tokens_l = list(tokenize.generate_tokens(io.StringIO(contents).readline))
tokens = reversed(tokens_l)
for token_type, token_text, (srow, scol), (erow, ecol), _ in tokens:
if token_type == tokenize.STRING:
new_text = handle_match(token_text)

View File

@ -12,9 +12,8 @@ class CalledProcessError(RuntimeError):
def added_files(): # type: () -> Set[str]
return set(cmd_output(
'git', 'diff', '--staged', '--name-only', '--diff-filter=A',
).splitlines())
cmd = ('git', 'diff', '--staged', '--name-only', '--diff-filter=A')
return set(cmd_output(*cmd).splitlines())
def cmd_output(*cmd, **kwargs): # type: (*str, **Any) -> str

View File

@ -121,9 +121,9 @@ def test_dict_no_allow_kwargs_exprs(expression, calls):
def test_ignore_constructors():
visitor = Visitor(ignore=(
'complex', 'dict', 'float', 'int', 'list', 'str', 'tuple',
))
visitor = Visitor(
ignore=('complex', 'dict', 'float', 'int', 'list', 'str', 'tuple'),
)
visitor.visit(ast.parse(BUILTIN_CONSTRUCTORS))
assert visitor.builtin_type_calls == []