lint: reformat python code with black
This commit is contained in:
parent
331beb01b4
commit
a406a7974b
88 changed files with 2579 additions and 1608 deletions
|
@ -17,31 +17,40 @@ class Activity(db.Model): # type: ignore
|
|||
text: Mapped[str]
|
||||
added: Mapped[datetime] = mapped_column(AwareDateTime())
|
||||
|
||||
def __init__(self, *,
|
||||
id: Optional[int] = None,
|
||||
group_id: Optional[int] = None,
|
||||
activity_type: str,
|
||||
text: str,
|
||||
added: Optional[datetime] = None,
|
||||
**kwargs: Any) -> None:
|
||||
if not isinstance(activity_type, str) or len(activity_type) > 20 or activity_type == "":
|
||||
raise TypeError("expected string for activity type between 1 and 20 characters")
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
id: Optional[int] = None,
|
||||
group_id: Optional[int] = None,
|
||||
activity_type: str,
|
||||
text: str,
|
||||
added: Optional[datetime] = None,
|
||||
**kwargs: Any
|
||||
) -> None:
|
||||
if (
|
||||
not isinstance(activity_type, str)
|
||||
or len(activity_type) > 20
|
||||
or activity_type == ""
|
||||
):
|
||||
raise TypeError(
|
||||
"expected string for activity type between 1 and 20 characters"
|
||||
)
|
||||
if not isinstance(text, str):
|
||||
raise TypeError("expected string for text")
|
||||
if added is None:
|
||||
added = datetime.now(tz=timezone.utc)
|
||||
super().__init__(id=id,
|
||||
group_id=group_id,
|
||||
activity_type=activity_type,
|
||||
text=text,
|
||||
added=added,
|
||||
**kwargs)
|
||||
super().__init__(
|
||||
id=id,
|
||||
group_id=group_id,
|
||||
activity_type=activity_type,
|
||||
text=text,
|
||||
added=added,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
def notify(self) -> int:
|
||||
count = 0
|
||||
hooks = Webhook.query.filter(
|
||||
Webhook.destroyed.is_(None)
|
||||
)
|
||||
hooks = Webhook.query.filter(Webhook.destroyed.is_(None))
|
||||
for hook in hooks:
|
||||
hook.send(self.text)
|
||||
count += 1
|
||||
|
@ -59,7 +68,7 @@ class Webhook(AbstractConfiguration):
|
|||
product="notify",
|
||||
provider=self.format,
|
||||
resource_type="conf",
|
||||
resource_id=str(self.id)
|
||||
resource_id=str(self.id),
|
||||
)
|
||||
|
||||
def send(self, text: str) -> None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue