Skip to content

Commit a2b8dca

Browse files
committed
fix: Change schema init to staticmethods
1 parent 94e0ed9 commit a2b8dca

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

SideBot/db/tags.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
class _Tags:
1414
"""Internal DB class for tags."""
1515

16-
async def write_schema(self: asyncpg.Connection) -> None:
16+
@staticmethod
17+
async def write_schema(conn: asyncpg.Connection) -> None:
1718
for x in [
1819
"""
1920
CREATE TYPE public.discorduser AS (
@@ -43,7 +44,7 @@ async def write_schema(self: asyncpg.Connection) -> None:
4344
"CREATE INDEX IF NOT EXISTS tags_guild_id_idx ON tags (guild_id, name)",
4445
]:
4546
with contextlib.suppress(asyncpg.exceptions.DuplicateObjectError):
46-
await self.execute(
47+
await conn.execute(
4748
x,
4849
)
4950

@@ -173,11 +174,12 @@ def __init__(
173174
self.id = ident
174175
self.tags = _Tags(conn)
175176

177+
@staticmethod
176178
async def write_schema(
177-
self: asyncpg.Connection,
179+
conn: asyncpg.Connection,
178180
) -> None:
179181
"""Tag class."""
180-
await _Tags.write_schema(self)
182+
await _Tags.write_schema(conn)
181183

182184
@classmethod
183185
async def get(

SideBot/utils/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def as_dict(self):
3030
}
3131

3232
@classmethod
33-
def from_dict(cls, data: dict):
33+
def from_dict(cls, data: dict) -> "DBConfig":
3434
return cls(
3535
data["user"],
3636
data["pass"],
@@ -52,7 +52,7 @@ def __init__(self, token: str, owner: int, db_url: str, cogs: list[str]):
5252
self.cogs = cogs
5353

5454
@classmethod
55-
def from_dict(cls, data: dict):
55+
def from_dict(cls, data: dict) -> "BotConfig":
5656
if "botDB" in data:
5757
return cls(data["discordToken"], data["owner"], DBConfig.from_dict(data["botDB"]).connect_str, data["cogs"])
5858
return cls(data["discordToken"], data["owner"], data["botDBURL"], data["cogs"])

0 commit comments

Comments
 (0)