mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2025-08-14 17:31:28 +08:00
Apply typing to all of pre-commit-hooks
This commit is contained in:
@ -5,10 +5,12 @@ from __future__ import unicode_literals
|
||||
import argparse
|
||||
import io
|
||||
import sys
|
||||
import xml.sax
|
||||
import xml.sax.handler
|
||||
from typing import Optional
|
||||
from typing import Sequence
|
||||
|
||||
|
||||
def check_xml(argv=None):
|
||||
def main(argv=None): # type: (Optional[Sequence[str]]) -> int
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('filenames', nargs='*', help='XML filenames to check.')
|
||||
args = parser.parse_args(argv)
|
||||
@ -17,7 +19,7 @@ def check_xml(argv=None):
|
||||
for filename in args.filenames:
|
||||
try:
|
||||
with io.open(filename, 'rb') as xml_file:
|
||||
xml.sax.parse(xml_file, xml.sax.ContentHandler())
|
||||
xml.sax.parse(xml_file, xml.sax.handler.ContentHandler())
|
||||
except xml.sax.SAXException as exc:
|
||||
print('{}: Failed to xml parse ({})'.format(filename, exc))
|
||||
retval = 1
|
||||
@ -25,4 +27,4 @@ def check_xml(argv=None):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(check_xml())
|
||||
sys.exit(main())
|
||||
|
Reference in New Issue
Block a user