From 23bd22b30548e7ab83bfe81abd666bfac2a77712 Mon Sep 17 00:00:00 2001
From: jvoisin <julien.voisin@dustri.org>
Date: Mon, 2 Apr 2018 19:11:59 +0200
Subject: [PATCH] Add more typing hints

---
 src/parser_factory.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/parser_factory.py b/src/parser_factory.py
index 226234b..812d95c 100644
--- a/src/parser_factory.py
+++ b/src/parser_factory.py
@@ -4,6 +4,10 @@ import pkgutil
 
 from . import abstract
 
+from typing import Type, TypeVar
+
+T = TypeVar('T', bound='abstract.AbstractParser')
+
 for module_loader, name, ispkg in pkgutil.walk_packages('.src'):
     if not name.startswith('src.'):
         continue
@@ -11,10 +15,9 @@ for module_loader, name, ispkg in pkgutil.walk_packages('.src'):
         continue
     importlib.import_module(name)
 
-def get_parser(filename: str):
+def get_parser(filename: str) -> (T, str):
     mtype, _ = mimetypes.guess_type(filename)
     for c in abstract.AbstractParser.__subclasses__():
         if mtype in c.mimetypes:
             return c(filename), mtype
-    print('factory: %s is not supported' % mtype)
     return None, mtype
-- 
GitLab