Skip to content

Commit 1d651e5

Browse files
committed
Fix type errors
1 parent 2b92cd1 commit 1d651e5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

app.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import math
6+
from typing import Union
67
from flask import Flask, render_template, redirect, url_for, request
78
from flask_sqlalchemy import SQLAlchemy
89
from werkzeug.wrappers import Response
@@ -120,7 +121,7 @@ def index() -> str: # get index page template
120121
"""
121122
Return the index page containing a user.
122123
"""
123-
user: User | None = User.query.first() # get first user
124+
user: Union[User, None] = User.query.first() # get first user
124125
# redirect to index page template
125126
return render_template("index.html", user=user)
126127

@@ -130,7 +131,7 @@ def add_xp() -> Response: # add XP
130131
"""
131132
Add XP (experience points) based on entered amount.
132133
"""
133-
user: User | None = User.query.first() # get first user
134+
user: Union[User, None] = User.query.first() # get first user
134135
user.add_xp(float(request.form["amount"])) # parse amount as float
135136
db.session.commit() # commit database changes
136137
return redirect(url_for("index")) # redirect to index page template

0 commit comments

Comments
 (0)