Skip to content

Commit a1ee487

Browse files
committed
chore: bump version 0.10.0
1 parent 3c962a2 commit a1ee487

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# PEP 621 project metadata
33
# See https://www.python.org/dev/peps/pep-0621/
44
name = "graia-amnesia"
5-
version = "0.9.0"
5+
version = "0.10.0"
66
authors = [
77
{name = "GreyElaina", email = "[email protected]"},
88
{name = "RF-Tar-Railt", email = "[email protected]"}

src/graia/amnesia/builtins/sqla/model.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,17 @@
1414
}
1515

1616

17-
def _setup_bind(cls: type["Base"]) -> None:
18-
bind_key: str | None = getattr(cls, "__bind_key__", None)
19-
20-
if bind_key is None:
21-
bind_key = ""
22-
23-
cls.__table__.info["bind_key"] = bind_key
24-
25-
2617
_callbacks = []
2718

2819

29-
def register_callback(callback: Callable[[type["Base"]], Any]) -> None:
20+
def register_callback(callback: Callable[[type["Base"], dict[str, Any]], Any]) -> None:
3021
"""
3122
Register a callback to be called when a new Base subclass is created.
32-
The callback should accept a single argument, which is the subclass itself.
3323
"""
3424
_callbacks.append(callback)
3525

3626

37-
def remove_callback(callback: Callable[[type["Base"]], Any]) -> None:
27+
def remove_callback(callback: Callable[[type["Base"], dict[str, Any]], Any]) -> None:
3828
"""
3929
Remove a previously registered callback.
4030
"""
@@ -51,7 +41,7 @@ class Base(AsyncAttrs, DeclarativeBase):
5141

5242
def __init_subclass__(cls, **kwargs):
5343
for callback in _callbacks:
54-
callback(cls)
44+
callback(cls, kwargs)
5545

5646
if not hasattr(cls, "__tablename__") and "tablename" in kwargs:
5747
cls.__tablename__ = kwargs["tablename"]
@@ -67,4 +57,9 @@ def __init_subclass__(cls, **kwargs):
6757
if not hasattr(cls, "__table__"):
6858
return
6959

70-
_setup_bind(cls)
60+
bind_key: str | None = getattr(cls, "__bind_key__", kwargs.get("bind_key", None))
61+
62+
if bind_key is None:
63+
bind_key = ""
64+
65+
cls.__table__.info["bind_key"] = bind_key

0 commit comments

Comments
 (0)