Skip to content

Commit 8f053cf

Browse files
committed
fix ruff
1 parent d1d0c4f commit 8f053cf

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/SideBot/db/tags.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import datetime
44
from collections.abc import AsyncGenerator
5-
from typing import Any, Optional
5+
from typing import Any
66

77
import asyncpg
88

@@ -92,12 +92,16 @@ async def create(
9292
used,
9393
)
9494

95-
async def save(self,tag_id:int, guild_id: int,
95+
async def save(
96+
self,
97+
tag_id: int,
98+
guild_id: int,
9699
tag_name: str,
97100
content: str,
98101
author: DiscordUser,
99102
button_links: list[ButtonLink],
100-
used: int = 0) -> None:
103+
used: int = 0,
104+
) -> None:
101105
"""Save a tag."""
102106
await self.conn.execute(
103107
"""UPDATE tags SET
@@ -109,7 +113,7 @@ async def save(self,tag_id:int, guild_id: int,
109113
author,
110114
button_links,
111115
used,
112-
tag_id
116+
tag_id,
113117
)
114118

115119
async def delete(self, guild_id: int, tag_name: str) -> None:
@@ -152,7 +156,7 @@ def __init__(
152156
updated_at: datetime.datetime,
153157
button_links: list[ButtonLink],
154158
used_count: int,
155-
ident: Optional[int],
159+
ident: int | None,
156160
conn: asyncpg.Connection,
157161
) -> None:
158162
"""Tag class."""
@@ -241,5 +245,9 @@ async def update(self) -> None:
241245
await self.tags.update(self.guildid, self.tagname, self.content)
242246

243247
async def save(self) -> None:
244-
assert self.id is not None
245-
await self.tags.save(self.id, self.guildid, self.tagname, self.content, self.author, self.button_links, self.used_count)
248+
"""Save a tag."""
249+
if not self.id:
250+
await self.create()
251+
await self.tags.save(
252+
self.id, self.guildid, self.tagname, self.content, self.author, self.button_links, self.used_count
253+
)

0 commit comments

Comments
 (0)