Skip to content

Commit

Permalink
Make the optional types actually optional, and remove a dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
YummyBacon5 authored May 3, 2024
1 parent c4b0b7f commit ab8b5d8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
20 changes: 9 additions & 11 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
from random import choice
from enum import Enum
import time
from typing import Annotated, List, Optional
from dotenv import load_dotenv
from typing import Annotated

from fastapi import FastAPI, HTTPException, Query, Request
from fastapi.middleware.cors import CORSMiddleware
Expand All @@ -16,8 +15,6 @@
from tinydb import TinyDB, where
from tinydb.operations import increment, decrement

load_dotenv()

db = TinyDB("dict-data/dict_db.json", create_dirs=True, separators=(",", ":"))
app = FastAPI(
title="Dict Backend",
Expand Down Expand Up @@ -77,11 +74,12 @@ class WordEdit(BaseModel):
secretKey: str
word: Annotated[str, Query(max_length=50)] = None
description: Annotated[str, Query(max_length=170)] = None
creationDate: Optional[int]
uploader: Optional[str]
updoots: Optional[int]
downdoots: Optional[int]
isRobot: Optional[bool]
creationDate: int = None
uploader: str = None
updoots: int = None
downdoots: int = None
isRobot: bool = None
tags: list[str] = None

# -------------------------------------------
# Output models
Expand All @@ -93,8 +91,8 @@ class Word(BaseModel):
id: int
word: str
description: str
creationDate: Optional[int]
uploader: Optional[str]
creationDate: int = None
uploader: str = None
updoots: int
downdoots: int
isRobot: bool
Expand Down
3 changes: 1 addition & 2 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ fastapi
pydantic
random-word
tinydb
uvicorn
python-dotenv
uvicorn

0 comments on commit ab8b5d8

Please sign in to comment.