Skip to content

Commit 166e420

Browse files
committed
Fix ruff lint errors
1 parent f6d4f76 commit 166e420

File tree

9 files changed

+22
-38
lines changed

9 files changed

+22
-38
lines changed

labconnect/errors/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66

77
error_blueprint = Blueprint("errors", __name__, template_folder="templates")
88

9-
from . import routes
9+
from . import routes # noqa

labconnect/errors/routes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from flask import Response, make_response, render_template
1+
from flask import Response, make_response
22

33
from . import error_blueprint
44

labconnect/helpers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import json
21
from enum import Enum as EnumPython
32

43
import orjson

labconnect/main/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66

77
main_blueprint = Blueprint("main", __name__)
88

9-
from . import auth_routes, discover_routes, opportunity_routes, routes
9+
from . import auth_routes, discover_routes, opportunity_routes, routes # noqa

labconnect/main/discover_routes.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from flask_jwt_extended import get_jwt_identity, jwt_required
2-
31
from labconnect import db
42
from labconnect.models import (
53
ClassYears,
@@ -35,7 +33,7 @@ def discover_data(jwt_identity, limit):
3533
Opportunities.location,
3634
LabManager.id.label("lab_manager_id"),
3735
)
38-
.where(Opportunities.active == True)
36+
.where(Opportunities.active)
3937
.join(
4038
RecommendsClassYears,
4139
Opportunities.id == RecommendsClassYears.class_year,
@@ -61,7 +59,7 @@ def discover_data(jwt_identity, limit):
6159
if jwt_identity is None or data is None:
6260
data = db.session.execute(
6361
db.select(Opportunities)
64-
.where(Opportunities.active == True)
62+
.where(Opportunities.active)
6563
.limit(limit)
6664
.order_by(Opportunities.last_updated.desc())
6765
).scalars()

labconnect/main/opportunity_routes.py

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ def packageIndividualOpportunity(opportunityInfo):
171171

172172

173173
def packageOpportunityCard(opportunity):
174-
175174
# get professor and department by getting Leads and LabManager
176175
query = db.session.execute(
177176
db.select(Leads, LabManager, User.first_name, User.last_name)
@@ -232,7 +231,7 @@ def getOpportunities():
232231
# Handle GET requests for fetching default active opportunities
233232
data = db.session.execute(
234233
db.select(Opportunities)
235-
.where(Opportunities.active == True)
234+
.where(Opportunities.active)
236235
.limit(20)
237236
.order_by(Opportunities.last_updated.desc())
238237
.distinct()
@@ -263,7 +262,7 @@ def filterOpportunities():
263262
where_conditions = []
264263
query = (
265264
db.select(Opportunities)
266-
.where(Opportunities.active == True)
265+
.where(Opportunities.active)
267266
.limit(20)
268267
.order_by(Opportunities.last_updated)
269268
.distinct()
@@ -462,9 +461,7 @@ def filterOpportunities():
462461
@main_blueprint.get("/getOpportunityCards")
463462
def getOpportunityCards():
464463
# query database for opportunity
465-
query = db.session.execute(
466-
db.select(Opportunities).where(Opportunities.active == True)
467-
)
464+
query = db.session.execute(db.select(Opportunities).where(Opportunities.active))
468465

469466
data = query.fetchall()
470467
# return data in the below format if opportunity is found
@@ -497,7 +494,6 @@ def getOpportunityCards():
497494

498495
@main_blueprint.get("/staff/opportunities/<string:rcs_id>")
499496
def getLabManagerOpportunityCards(rcs_id: str) -> list[dict[str, str]]:
500-
501497
query = (
502498
db.select(
503499
Opportunities.id,
@@ -534,7 +530,6 @@ def getLabManagerOpportunityCards(rcs_id: str) -> list[dict[str, str]]:
534530

535531
@main_blueprint.get("/profile/opportunities/<string:rcs_id>")
536532
def getProfileOpportunities(rcs_id: str) -> list[dict[str, str]]:
537-
538533
query = (
539534
db.select(
540535
Opportunities.id,
@@ -661,7 +656,7 @@ def createOpportunity():
661656

662657
try:
663658
pay = int(request_data["hourlyPay"])
664-
except:
659+
except ValueError:
665660
pay = None
666661

667662
one = True if "1" in request_data["credits"] else False
@@ -769,7 +764,9 @@ def editOpportunity_get(opportunity_id):
769764
"type": (
770765
"Any"
771766
if len(credits) > 0 and opportunity.pay and opportunity.pay > 0
772-
else "For Pay" if opportunity.pay and opportunity.pay > 0 else "For Credit"
767+
else "For Pay"
768+
if opportunity.pay and opportunity.pay > 0
769+
else "For Credit"
773770
),
774771
"hourlyPay": str(opportunity.pay),
775772
"credits": credits,
@@ -791,7 +788,6 @@ def editOpportunity_get(opportunity_id):
791788
@main_blueprint.put("/editOpportunity/<int:opportunity_id>")
792789
@jwt_required()
793790
def editOpportunity(opportunity_id):
794-
795791
user_id = get_jwt_identity()
796792
if not request.data or not user_id:
797793
abort(400)
@@ -827,7 +823,7 @@ def editOpportunity(opportunity_id):
827823

828824
try:
829825
pay = int(request_data["hourlyPay"])
830-
except:
826+
except ValueError:
831827
pay = None
832828

833829
one = True if "1" in request_data["credits"] else False
@@ -889,14 +885,14 @@ def editOpportunity(opportunity_id):
889885
db.session.commit()
890886

891887
# Add the updated list of managers
892-
if "lab_manager_ids" in data:
893-
for lab_manager_id in data["lab_manager_ids"]:
894-
new_lead = Leads(
895-
lab_manager_id=lab_manager_id, opportunity_id=opportunity_id
896-
)
897-
db.session.add(new_lead)
898-
899-
db.session.commit() # Commit all changes
888+
# if "lab_manager_ids" in data:
889+
# for lab_manager_id in data["lab_manager_ids"]:
890+
# new_lead = Leads(
891+
# lab_manager_id=lab_manager_id, opportunity_id=opportunity_id
892+
# )
893+
# db.session.add(new_lead)
894+
895+
# db.session.commit() # Commit all changes
900896

901897
return {"data": "Opportunity Updated"}, 200
902898

labconnect/main/routes.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ def departmentCards():
4141

4242
@main_blueprint.get("/departments/<string:department>")
4343
def departmentDetails(department: str):
44-
4544
department_data = db.session.execute(
4645
db.select(
4746
RPIDepartments.id,
@@ -92,7 +91,6 @@ def departmentDetails(department: str):
9291
@main_blueprint.get("/profile")
9392
@jwt_required()
9493
def profile():
95-
9694
user_id = get_jwt_identity()
9795

9896
data = db.session.execute(
@@ -133,7 +131,6 @@ def profile():
133131
@main_blueprint.get("/staff/<string:id>")
134132
@jwt_required()
135133
def getProfessorProfile(id: str):
136-
137134
data = db.session.execute(
138135
db.select(
139136
User.preferred_name,
@@ -208,7 +205,6 @@ def force_error():
208205

209206
@main_blueprint.get("/majors")
210207
def majors() -> list[dict[str, str]]:
211-
212208
data = db.session.execute(db.select(Majors).order_by(Majors.code)).scalars()
213209

214210
if not data:
@@ -224,11 +220,8 @@ def majors() -> list[dict[str, str]]:
224220

225221
@main_blueprint.get("/years")
226222
def years() -> list[int]:
227-
228223
data = db.session.execute(
229-
db.select(ClassYears)
230-
.order_by(ClassYears.class_year)
231-
.where(ClassYears.active == True)
224+
db.select(ClassYears).order_by(ClassYears.class_year).where(ClassYears.active)
232225
).scalars()
233226

234227
if not data:

labconnect/models.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from atexit import register
21
from sqlalchemy import Enum, Index, event, func
32
from sqlalchemy.dialects.postgresql import TSVECTOR
43

tests/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import pytest
22

33
from labconnect import create_app
4-
from labconnect.models import *
54

65
# --------
76
# Fixtures

0 commit comments

Comments
 (0)