Merge pull request #443 from pre-commit/fix_ci

Fix CI by upgrading AP templates
This commit is contained in:
Anthony Sottile 2020-02-03 08:46:21 -08:00 committed by GitHub
commit fd9a0c6cfd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 39 additions and 34 deletions

View file

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

View file

@ -10,7 +10,7 @@ resources:
type: github type: github
endpoint: github endpoint: github
name: asottile/azure-pipeline-templates name: asottile/azure-pipeline-templates
ref: refs/tags/v0.0.8 ref: refs/tags/v1.0.0
jobs: jobs:
- template: job--pre-commit.yml@asottile - 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: with open(filename, 'rb') as f:
ast.parse(f.read(), filename=filename) ast.parse(f.read(), filename=filename)
except SyntaxError: except SyntaxError:
print('{}: failed parsing with {} {}:'.format( print(
filename, '{}: failed parsing with {} {}:'.format(
platform.python_implementation(), filename,
sys.version.partition(' ')[0], platform.python_implementation(),
)) sys.version.partition(' ')[0],
print('\n{}'.format( ),
' ' + traceback.format_exc().replace('\n', '\n '), )
)) tb = ' ' + traceback.format_exc().replace('\n', '\n ')
print('\n{}'.format(tb))
retval = 1 retval = 1
return retval return retval

View file

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

View file

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

View file

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

View file

@ -12,9 +12,8 @@ class CalledProcessError(RuntimeError):
def added_files(): # type: () -> Set[str] def added_files(): # type: () -> Set[str]
return set(cmd_output( cmd = ('git', 'diff', '--staged', '--name-only', '--diff-filter=A')
'git', 'diff', '--staged', '--name-only', '--diff-filter=A', return set(cmd_output(*cmd).splitlines())
).splitlines())
def cmd_output(*cmd, **kwargs): # type: (*str, **Any) -> str 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(): def test_ignore_constructors():
visitor = Visitor(ignore=( visitor = Visitor(
'complex', 'dict', 'float', 'int', 'list', 'str', 'tuple', ignore=('complex', 'dict', 'float', 'int', 'list', 'str', 'tuple'),
)) )
visitor.visit(ast.parse(BUILTIN_CONSTRUCTORS)) visitor.visit(ast.parse(BUILTIN_CONSTRUCTORS))
assert visitor.builtin_type_calls == [] assert visitor.builtin_type_calls == []