diff --git a/SmsClient.py b/SmsClient.py index 2516738..0bb5c25 100644 --- a/SmsClient.py +++ b/SmsClient.py @@ -22,7 +22,7 @@ def __init__(self, settings: Settings, db: Database | None = None): @override def send_message(self, to: str, text: str) -> None: - self.twilio_client.messages.create( # pyright: ignore [reportUnknownMemberType] + self.twilio_client.messages.create( to=to, from_=settings.twilio_phone_number, body=text ) diff --git a/TextTestClient.py b/TextTestClient.py index 98da56b..e80a068 100644 --- a/TextTestClient.py +++ b/TextTestClient.py @@ -24,7 +24,7 @@ def handle_beta_message(self, from_: str, text: str): if __name__ == "__main__": - client = TextTestClient() + client = TextTestClient(settings) while True: text = input() diff --git a/database.py b/database.py index bc20286..6135fff 100644 --- a/database.py +++ b/database.py @@ -25,7 +25,7 @@ def get_db() -> Generator[Session]: class Database: - def __init__(self): + def __init__(self) -> None: db = next(get_db(), None) if db is None: raise Exception("Could not connect to database") @@ -86,9 +86,9 @@ def update_reg( if db_reg is None: return None - db_reg.state = state # pyright: ignore [reportAttributeAccessIssue] + db_reg.state = state if username is not None: - db_reg.username = username # pyright: ignore [reportAttributeAccessIssue] + db_reg.username = username self.db.commit() return db_reg @@ -162,6 +162,6 @@ def set_winner(self, pic_id: int): if pic is None: return None - pic.winner = not pic.winner # pyright: ignore [reportAttributeAccessIssue] + pic.winner = not pic.winner self.db.commit() return pic diff --git a/main.py b/main.py index 2edc200..9a5b357 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,3 @@ -# pyright: reportCallInDefaultInitializer=false - import logging from typing import Annotated @@ -25,7 +23,7 @@ logger = logging.getLogger(__name__) -models.Base.metadata.create_all(bind=engine) # pyright: ignore [reportAny] +models.Base.metadata.create_all(bind=engine) app = FastAPI() twilio_client = SmsClient(settings) @@ -61,7 +59,7 @@ async def receive_message( validator = RequestValidator(settings.twilio_auth_token) form_ = await request.form() - if not validator.validate( # pyright: ignore [reportUnknownMemberType] + if not validator.validate( str(request.url), form_, request.headers.get("X-Twilio-Signature", "") ): raise HTTPException(status_code=400, detail="Error in Twilio Signature") @@ -101,21 +99,19 @@ def images_page( if prompt is None: raise HTTPException(status_code=404, detail="Unable to find prompt") - if not db.get_submission_status( - user_hash, prompt.id # pyright: ignore [reportArgumentType] - ): + if not db.get_submission_status(user_hash, prompt.id): raise HTTPException(status_code=401, detail="No submission for this prompt") - pics = db.get_pics_by_prompt(prompt.id) # pyright: ignore [reportArgumentType] + pics = db.get_pics_by_prompt(prompt.id) pics = [vars(pic) for pic in pics] for pic in pics: pic["click_url"] = pic["url"] - date_str: str = prompt.date.strftime("%b %-d, %Y") # pyright: ignore [reportAny] + date_str: str = prompt.date.strftime("%b %-d, %Y") og = {"display": False} - winner = db.get_winner_by_prompt(prompt.id) # pyright: ignore [reportArgumentType] + winner = db.get_winner_by_prompt(prompt.id) if winner is not None: og["display"] = True og["url"] = winner.url @@ -132,7 +128,7 @@ def history_page(user_hash: str): pics = db.get_pics_by_hash(user_hash) html_list: list[str] = [] for pic in pics: - prompt = db.get_prompt(pic.prompt) # pyright: ignore [reportArgumentType] + prompt = db.get_prompt(pic.prompt) assert prompt is not None url = BASE_URL + "{}?n={}".format(user_hash, prompt.id) html_list.append('