Skip to content

Commit

Permalink
Resolve circular import
Browse files Browse the repository at this point in the history
  • Loading branch information
jdabtieu committed Jul 27, 2023
1 parent 36702aa commit bb60741
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
10 changes: 1 addition & 9 deletions src/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from io import BytesIO

Check warning on line 8 in src/application.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

F401 'io.BytesIO' imported but unused

Check warning on line 8 in src/application.py

View workflow job for this annotation

GitHub Actions / build (windows-latest)

F401 'io.BytesIO' imported but unused

import jwt
from cs50 import SQL
from flask import (abort, Flask, flash, redirect, render_template, request,

Check warning on line 11 in src/application.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

F401 'flask.send_file' imported but unused

Check warning on line 11 in src/application.py

View workflow job for this annotation

GitHub Actions / build (windows-latest)

F401 'flask.send_file' imported but unused
send_from_directory, send_file, session)
from flask_mail import Mail
Expand All @@ -18,6 +17,7 @@
from werkzeug.security import check_password_hash, generate_password_hash

from helpers import * # noqa
from db import db
from middlewares import ProxyFix

app = Flask(__name__)
Expand Down Expand Up @@ -56,14 +56,6 @@
# Configure flask-session
Session(app)

# Configure cs50
try:
db = SQL("sqlite:///database.db")
except Exception as e: # when testing
sys.stderr.write(str(e))
open("database_test.db", "w").close()
db = SQL("sqlite:///database_test.db")

# Configure flask-mail
mail = Mail(app)

Expand Down
10 changes: 10 additions & 0 deletions src/db.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from cs50 import SQL
import sys


try:
db = SQL("sqlite:///database.db")
except Exception as e: # when testing
sys.stderr.write(str(e))
open("database_test.db", "w").close()
db = SQL("sqlite:///database_test.db")
2 changes: 1 addition & 1 deletion src/views/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from werkzeug.security import generate_password_hash

from helpers import * # noqa
from application import db
from db import db

api = Blueprint("admin", __name__)

Expand Down
2 changes: 1 addition & 1 deletion src/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging

from helpers import * # noqa
from application import db
from db import db

api = Blueprint("api", __name__)

Expand Down
2 changes: 1 addition & 1 deletion src/views/contest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


from helpers import * # noqa
from application import db
from db import db

api = Blueprint("contest", __name__)

Expand Down
2 changes: 1 addition & 1 deletion src/views/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


from helpers import * # noqa
from application import db
from db import db

api = Blueprint("problem", __name__)

Expand Down

0 comments on commit bb60741

Please sign in to comment.