Fix typing in factory method

This commit is contained in:
Daniel Goldberg 2019-11-12 20:07:48 +02:00
parent e9538e9a42
commit 31a60b12ff
1 changed files with 5 additions and 2 deletions

View File

@ -4,7 +4,7 @@ import logging
from abc import ABCMeta, abstractmethod
from os.path import dirname, basename, isfile, join
import glob
from typing import Sequence
from typing import Sequence, TypeVar, Type
LOG = logging.getLogger(__name__)
@ -14,6 +14,9 @@ def _get_candidate_files(base_package_file):
return [basename(f)[:-3] for f in files if isfile(f) and not f.endswith('__init__.py')]
Plugin_type = TypeVar('Plugin_type', bound='Plugin')
class Plugin(metaclass=ABCMeta):
@staticmethod
@ -22,7 +25,7 @@ class Plugin(metaclass=ABCMeta):
raise NotImplementedError()
@classmethod
def get_instances(cls) -> Sequence[object]:
def get_instances(cls) -> Sequence[Type[Plugin_type]]:
"""
Returns the type objects from base_package_spec.
base_package name and file must refer to the same package otherwise bad results