cli/automate: fix up errors found with mypy
This commit is contained in:
parent
55a0b19c8c
commit
ccf0ce6a06
3 changed files with 55 additions and 22 deletions
|
@ -1,4 +1,5 @@
|
|||
import datetime
|
||||
from typing import Any, Optional
|
||||
|
||||
import requests
|
||||
|
||||
|
@ -13,14 +14,25 @@ class Activity(db.Model):
|
|||
text = db.Column(db.Text(), nullable=False)
|
||||
added = db.Column(db.DateTime(), nullable=False)
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
if type(kwargs["activity_type"]) != str or len(kwargs["activity_type"]) > 20 or kwargs["activity_type"] == "":
|
||||
def __init__(self, *,
|
||||
id: Optional[int] = None,
|
||||
group_id: Optional[int] = None,
|
||||
activity_type: str,
|
||||
text: str,
|
||||
added: Optional[datetime.datetime] = None,
|
||||
**kwargs: Any) -> None:
|
||||
if type(activity_type) != str or len(activity_type) > 20 or activity_type == "":
|
||||
raise TypeError("expected string for activity type between 1 and 20 characters")
|
||||
if type(kwargs["text"]) != str:
|
||||
if type(text) != str:
|
||||
raise TypeError("expected string for text")
|
||||
if "added" not in kwargs:
|
||||
kwargs["added"] = datetime.datetime.utcnow()
|
||||
super().__init__(**kwargs)
|
||||
super().__init__(id=id,
|
||||
group_id=group_id,
|
||||
activity_type=activity_type,
|
||||
text=text,
|
||||
added=added,
|
||||
**kwargs)
|
||||
if self.added is None:
|
||||
self.added = datetime.datetime.utcnow()
|
||||
|
||||
def notify(self) -> int:
|
||||
count = 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue