mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-05-31 16:16:11 +08:00
♻️ 复原 RegistryMeta 的位置
This commit is contained in:
parent
e8f0d578e1
commit
fd349eefed
@ -16,7 +16,7 @@ from nonebot_plugin_saa import PlatformTarget
|
||||
from ..post import Post
|
||||
from ..utils import Site, ProcessContext
|
||||
from ..plugin_config import plugin_config
|
||||
from ..types import Tag, Target, RawPost, SubUnit, Category, RegistryMeta
|
||||
from ..types import Tag, Target, RawPost, SubUnit, Category
|
||||
|
||||
|
||||
class CategoryNotSupport(Exception):
|
||||
@ -29,6 +29,21 @@ class CategoryNotRecognize(Exception):
|
||||
"""raise in get_category, when you don't know the category of post"""
|
||||
|
||||
|
||||
class RegistryMeta(type):
|
||||
def __new__(cls, name, bases, namespace, **kwargs):
|
||||
return super().__new__(cls, name, bases, namespace)
|
||||
|
||||
def __init__(cls, name, bases, namespace, **kwargs):
|
||||
if kwargs.get("base"):
|
||||
# this is the base class
|
||||
cls.registry = []
|
||||
elif not kwargs.get("abstract"):
|
||||
# this is the subclass
|
||||
cls.registry.append(cls)
|
||||
|
||||
super().__init__(name, bases, namespace, **kwargs)
|
||||
|
||||
|
||||
P = ParamSpec("P")
|
||||
R = TypeVar("R")
|
||||
|
||||
|
@ -58,18 +58,3 @@ class ApiError(Exception):
|
||||
class SubUnit(NamedTuple):
|
||||
sub_target: Target
|
||||
user_sub_infos: list[UserSubInfo]
|
||||
|
||||
|
||||
class RegistryMeta(type):
|
||||
def __new__(cls, name, bases, namespace, **kwargs):
|
||||
return super().__new__(cls, name, bases, namespace)
|
||||
|
||||
def __init__(cls, name, bases, namespace, **kwargs):
|
||||
if kwargs.get("base"):
|
||||
# this is the base class
|
||||
cls.registry = []
|
||||
elif not kwargs.get("abstract"):
|
||||
# this is the subclass
|
||||
cls.registry.append(cls)
|
||||
|
||||
super().__init__(name, bases, namespace, **kwargs)
|
||||
|
Loading…
x
Reference in New Issue
Block a user