Merge branch 'master' of https://gitlab.com/Lucidiot/objtools
This commit is contained in:
commit
33144e022c
|
@ -1,5 +1,4 @@
|
|||
from typing import MutableMapping, Any, Callable
|
||||
from cached_property import cached_property
|
||||
from typing import Dict, Any, Callable
|
||||
|
||||
|
||||
class ClassRegistry(MutableMapping[str, Callable]):
|
||||
|
@ -35,13 +34,18 @@ class ClassRegistry(MutableMapping[str, Callable]):
|
|||
self.check(key, value)
|
||||
super().__setitem__(key, value)
|
||||
|
||||
@cached_property
|
||||
def metaclass(self) -> type:
|
||||
class RegistryMetaclass(type):
|
||||
|
||||
def __new__(cls, name: str, *args: Any, **kwargs: Any) -> type:
|
||||
def __new__(cls,
|
||||
name: str,
|
||||
*args: Any,
|
||||
register: bool = True,
|
||||
key: Optional[str] = None,
|
||||
**kwargs: Any) -> type:
|
||||
newclass = super().__new__(cls, name, *args, **kwargs)
|
||||
self.register(name, newclass)
|
||||
if register:
|
||||
self.register(key or name, newclass)
|
||||
return newclass
|
||||
|
||||
return RegistryMetaclass
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
cached-property>=1.5.1
|
3
setup.py
3
setup.py
|
@ -7,7 +7,8 @@ def read_requirements(filename: str) -> List[str]:
|
|||
return [req.strip() for req in open(filename)]
|
||||
|
||||
|
||||
requirements = read_requirements('requirements.txt')
|
||||
# requirements = read_requirements('requirements.txt')
|
||||
requirements = []
|
||||
dev_requirements = read_requirements('requirements-dev.txt')
|
||||
|
||||
setup(
|
||||
|
|
Loading…
Reference in New Issue