mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2025-08-14 09:27:21 +08:00
pre-commit-hooks: python3.6+
This commit is contained in:
@ -1,7 +1,3 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import argparse
|
||||
import ast
|
||||
import platform
|
||||
@ -11,7 +7,7 @@ from typing import Optional
|
||||
from typing import Sequence
|
||||
|
||||
|
||||
def main(argv=None): # type: (Optional[Sequence[str]]) -> int
|
||||
def main(argv: Optional[Sequence[str]] = None) -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('filenames', nargs='*')
|
||||
args = parser.parse_args(argv)
|
||||
@ -23,15 +19,11 @@ 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],
|
||||
),
|
||||
)
|
||||
impl = platform.python_implementation()
|
||||
version = sys.version.split()[0]
|
||||
print(f'{filename}: failed parsing with {impl} {version}:')
|
||||
tb = ' ' + traceback.format_exc().replace('\n', '\n ')
|
||||
print('\n{}'.format(tb))
|
||||
print(f'\n{tb}')
|
||||
retval = 1
|
||||
return retval
|
||||
|
||||
|
Reference in New Issue
Block a user