Skip to content

Commit 3f2220e

Browse files
committed
issue-814 fix formatting for python files
1 parent 70ff1e5 commit 3f2220e

11 files changed

Lines changed: 67 additions & 37 deletions

File tree

bases/rsptx/admin_server_api/routers/instructor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,7 @@ async def post_create_course_page(
12571257
# if invoice is true then we need to create an invoice for the course
12581258
if invoice == "true":
12591259
res = await create_invoice_request(
1260-
user.username, projectname, 0.0, user.email
1260+
user.username, projectname, 0.0, user.email
12611261
)
12621262
# Copy attributes from base course
12631263
bc = await fetch_course(coursetype)

bases/rsptx/admin_server_api/routers/lti1p3.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,10 @@ async def launch(request: Request):
446446
status_code=400, detail=f"Assignment {lineitem_assign_id} not found"
447447
)
448448

449-
if not is_assignment_visible_to_students(rs_assign) and not message_launch.check_teacher_access():
449+
if (
450+
not is_assignment_visible_to_students(rs_assign)
451+
and not message_launch.check_teacher_access()
452+
):
450453
raise HTTPException(
451454
status_code=400,
452455
detail=f"Assignment {rs_assign.name} is not open for students",

bases/rsptx/assignment_server_api/routers/instructor.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@
7171
delete_datafile,
7272
)
7373
from rsptx.db.crud.question import validate_question_name_unique, copy_question
74-
from rsptx.db.crud.assignment import add_assignment_question, delete_assignment, is_assignment_visible_to_students
74+
from rsptx.db.crud.assignment import (
75+
add_assignment_question,
76+
delete_assignment,
77+
is_assignment_visible_to_students,
78+
)
7579
from rsptx.auth.session import auth_manager, is_instructor
7680
from rsptx.templates import template_folder
7781
from rsptx.configuration import settings
@@ -1218,9 +1222,9 @@ async def do_download_assignment(
12181222
csv_buffer,
12191223
media_type="text/csv",
12201224
)
1221-
response.headers["Content-Disposition"] = (
1222-
f"attachment; filename=assignment_{assignment_id}.csv"
1223-
)
1225+
response.headers[
1226+
"Content-Disposition"
1227+
] = f"attachment; filename=assignment_{assignment_id}.csv"
12241228

12251229
return response
12261230

bases/rsptx/assignment_server_api/routers/student.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,12 @@ async def get_assignments(
107107
# Also include assignments the student has deadline exceptions for,
108108
# even if they are not currently visible via scheduled dates
109109
if assignment_ids:
110-
all_assignments = await fetch_assignments(course.course_name, fetch_all=True)
110+
all_assignments = await fetch_assignments(
111+
course.course_name, fetch_all=True
112+
)
111113
exception_assignments = [
112-
a for a in all_assignments
114+
a
115+
for a in all_assignments
113116
if a.id in assignment_ids and not is_assignment_visible_to_students(a)
114117
]
115118
assignments = list(assignments) + exception_assignments
@@ -121,15 +124,19 @@ def sort_key(assignment):
121124
deadline = assignment.duedate
122125
if timezoneoffset:
123126
deadline = deadline + datetime.timedelta(hours=float(timezoneoffset))
124-
return (deadline < canonical_utcnow(), abs((deadline - canonical_utcnow()).total_seconds()))
127+
return (
128+
deadline < canonical_utcnow(),
129+
abs((deadline - canonical_utcnow()).total_seconds()),
130+
)
125131
else:
126-
return (assignment.duedate < canonical_utcnow(), abs((assignment.duedate - canonical_utcnow()).total_seconds()))
132+
return (
133+
assignment.duedate < canonical_utcnow(),
134+
abs((assignment.duedate - canonical_utcnow()).total_seconds()),
135+
)
127136

128137
# Sort assignments: upcoming assignments first (closest to current date), past due assignments last
129138
now = canonical_utcnow()
130-
assignments.sort(
131-
key=sort_key
132-
)
139+
assignments.sort(key=sort_key)
133140
stats_list = await fetch_all_assignment_stats(course.course_name, user.id)
134141
stats = {}
135142
for s in stats_list:

bases/rsptx/book_server_api/routers/course.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,12 @@ async def index(
101101
# Also include assignments the student has deadline exceptions for,
102102
# even if they are not currently visible via scheduled dates
103103
if assignment_ids:
104-
all_assignments = await fetch_assignments(course.course_name, fetch_all=True)
104+
all_assignments = await fetch_assignments(
105+
course.course_name, fetch_all=True
106+
)
105107
exception_assignments = [
106-
a for a in all_assignments
108+
a
109+
for a in all_assignments
107110
if a.id in assignment_ids and not is_assignment_visible_to_students(a)
108111
]
109112
assignments = list(assignments) + exception_assignments
@@ -127,9 +130,7 @@ def sort_key(assignment):
127130
)
128131

129132
now = canonical_utcnow()
130-
assignments.sort(
131-
key=sort_key
132-
)
133+
assignments.sort(key=sort_key)
133134

134135
stats_list = await fetch_all_assignment_stats(course_name, user.id)
135136
stats = {}

bases/rsptx/rsmanage/core.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,9 @@ async def addcourse(
312312
basecourse = click.prompt("Base Course: ")
313313
bookrec = await fetch_library_book(basecourse)
314314
if not bookrec:
315-
click.echo(f"{basecourse} Not Found: Please add the book first using `addbookauthor")
315+
click.echo(
316+
f"{basecourse} Not Found: Please add the book first using `addbookauthor"
317+
)
316318
exit(1)
317319
if bookrec and bookrec.build_system is None:
318320
click.echo(
@@ -955,7 +957,9 @@ def grade(config, course, pset, enforce):
955957
)
956958
@click.option("--sample_size", help="Number of courses to sample", default=0)
957959
@click.option("--course_list", help="List of courses to sample", default=None)
958-
@click.option("--preserve_user_ids", is_flag=True, help="Preserve user ids in the datashop export")
960+
@click.option(
961+
"--preserve_user_ids", is_flag=True, help="Preserve user ids in the datashop export"
962+
)
959963
@pass_config
960964
async def datashop(config, basecourse, sample_size, course_list, preserve_user_ids):
961965
"""Export the course data to the datashop format"""

components/rsptx/build_tools/build.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -431,9 +431,9 @@ def wheel(config):
431431

432432
res = subprocess.run(lock_opts, capture_output=True)
433433
if res.returncode != 0:
434-
status[proj] = (
435-
f"[red]Fail[/red] probable dependency conflict see {projdir}/build.log"
436-
)
434+
status[
435+
proj
436+
] = f"[red]Fail[/red] probable dependency conflict see {projdir}/build.log"
437437
lt.update(generate_wheel_table(status))
438438
if config.verbose:
439439
console.print(
@@ -894,7 +894,8 @@ def dev(ctx, config):
894894
ctx.invoke(image)
895895
ctx.invoke(restart)
896896

897-
# This command should be used when you pull new code from github and want to rebuild and make
897+
898+
# This command should be used when you pull new code from github and want to rebuild and make
898899
# sure you are using the latest database schema. Many people forget to run migrations
899900
# after pulling new code.
900901
@cli.command()

components/rsptx/build_tools/core.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def _build_ptx_book(config, gen, manifest, course, click=click, target="runeston
191191

192192
if rs.output_dir_abspath().exists():
193193
shutil.rmtree(rs.output_dir_abspath())
194-
194+
195195
click.echo("Building the book")
196196
if gen:
197197
click.echo("Generating assets")
@@ -341,7 +341,7 @@ def check_project_ptx(click=click, course=None, target="runestone"):
341341
tgt.output_dir = Path(docid)
342342

343343
tgt.stringparams.update({"host-platform": "runestone"})
344-
344+
345345
return tgt
346346

347347

@@ -705,7 +705,10 @@ def _process_single_chapter(sess, db_context, chapter, chap_num, course_name):
705705
res = sess.execute(ins)
706706
return res.inserted_primary_key[0]
707707

708+
708709
import pdb
710+
711+
709712
def _process_subchapters(sess, db_context, chapter, chapid, course_name):
710713
"""Process all subchapters for a given chapter."""
711714
subchap = 0
@@ -721,8 +724,10 @@ def _process_subchapters(sess, db_context, chapter, chapid, course_name):
721724
# at this point (7/28/2025) the only reason for a subsubchapter
722725
# is to have a timed assignment, so we can skip the rest of the
723726
# find all divs with a class of timedAssessment
724-
#pdb.set_trace()
725-
for timed_assessment_div in subchapter.findall(".//div[@class='timedAssessment']"):
727+
# pdb.set_trace()
728+
for timed_assessment_div in subchapter.findall(
729+
".//div[@class='timedAssessment']"
730+
):
726731
_process_single_timed_assignment(
727732
sess,
728733
db_context,

components/rsptx/db/crud/assignment.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ async def fetch_assignments(
267267
Assignment.visible_on.isnot(None),
268268
Assignment.hidden_on.isnot(None),
269269
Assignment.visible_on <= now,
270-
Assignment.hidden_on > now
270+
Assignment.hidden_on > now,
271271
),
272272
# Case 2: "Visible on" mode (visible once visible_on passes)
273273
and_(
@@ -282,8 +282,8 @@ async def fetch_assignments(
282282
# visible_on check
283283
or_(Assignment.visible_on.is_(None), Assignment.visible_on <= now),
284284
# hidden_on check
285-
or_(Assignment.hidden_on.is_(None), Assignment.hidden_on > now)
286-
)
285+
or_(Assignment.hidden_on.is_(None), Assignment.hidden_on > now),
286+
),
287287
)
288288
else:
289289
vclause = True

components/rsptx/db/crud/rsfiles.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99

1010
# We need a synchronous version of this function for use in manifest_data_to_db
1111
# if/when process_manifest moves to being async we could remove this
12-
def update_source_code_sync(acid: str, filename: str, course_id: str, main_code: str, owner: str = None):
12+
def update_source_code_sync(
13+
acid: str, filename: str, course_id: str, main_code: str, owner: str = None
14+
):
1315
"""
1416
Update the source code for a given acid or filename
1517
"""
@@ -40,7 +42,9 @@ def update_source_code_sync(acid: str, filename: str, course_id: str, main_code:
4042
session.commit()
4143

4244

43-
async def update_source_code(acid: str, filename: str, course_id: str, main_code: str, owner: str = None):
45+
async def update_source_code(
46+
acid: str, filename: str, course_id: str, main_code: str, owner: str = None
47+
):
4448
"""
4549
Update the source code for a given acid or filename
4650
"""
@@ -253,6 +257,3 @@ async def delete_datafile(acid: str, course_id: str) -> bool:
253257
await session.delete(source_code_obj)
254258
await session.commit()
255259
return True
256-
257-
258-

0 commit comments

Comments
 (0)