forked from p34709852/monkey
Fix typing in factory method
This commit is contained in:
parent
e9538e9a42
commit
31a60b12ff
|
@ -4,7 +4,7 @@ import logging
|
||||||
from abc import ABCMeta, abstractmethod
|
from abc import ABCMeta, abstractmethod
|
||||||
from os.path import dirname, basename, isfile, join
|
from os.path import dirname, basename, isfile, join
|
||||||
import glob
|
import glob
|
||||||
from typing import Sequence
|
from typing import Sequence, TypeVar, Type
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
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')]
|
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):
|
class Plugin(metaclass=ABCMeta):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -22,7 +25,7 @@ class Plugin(metaclass=ABCMeta):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_instances(cls) -> Sequence[object]:
|
def get_instances(cls) -> Sequence[Type[Plugin_type]]:
|
||||||
"""
|
"""
|
||||||
Returns the type objects from base_package_spec.
|
Returns the type objects from base_package_spec.
|
||||||
base_package name and file must refer to the same package otherwise bad results
|
base_package name and file must refer to the same package otherwise bad results
|
||||||
|
|
Loading…
Reference in New Issue