Skip to content
Snippets Groups Projects
Commit 23bd22b3 authored by Julien (jvoisin) Voisin's avatar Julien (jvoisin) Voisin
Browse files

Add more typing hints

parent 6868f200
Branches
Tags
No related merge requests found
...@@ -4,6 +4,10 @@ import pkgutil ...@@ -4,6 +4,10 @@ import pkgutil
from . import abstract from . import abstract
from typing import Type, TypeVar
T = TypeVar('T', bound='abstract.AbstractParser')
for module_loader, name, ispkg in pkgutil.walk_packages('.src'): for module_loader, name, ispkg in pkgutil.walk_packages('.src'):
if not name.startswith('src.'): if not name.startswith('src.'):
continue continue
...@@ -11,10 +15,9 @@ for module_loader, name, ispkg in pkgutil.walk_packages('.src'): ...@@ -11,10 +15,9 @@ for module_loader, name, ispkg in pkgutil.walk_packages('.src'):
continue continue
importlib.import_module(name) importlib.import_module(name)
def get_parser(filename: str): def get_parser(filename: str) -> (T, str):
mtype, _ = mimetypes.guess_type(filename) mtype, _ = mimetypes.guess_type(filename)
for c in abstract.AbstractParser.__subclasses__(): for c in abstract.AbstractParser.__subclasses__():
if mtype in c.mimetypes: if mtype in c.mimetypes:
return c(filename), mtype return c(filename), mtype
print('factory: %s is not supported' % mtype)
return None, mtype return None, mtype
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment