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

@ -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