Skip to content

Commit e8f5199

Browse files
committed
Format code with black
1 parent e170a13 commit e8f5199

14 files changed

Lines changed: 78 additions & 45 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
@@ -1227,7 +1227,7 @@ async def post_create_course_page(
12271227
# if invoice is true then we need to create an invoice for the course
12281228
if invoice == "true":
12291229
res = await create_invoice_request(
1230-
user.username, projectname, 0.0, user.email
1230+
user.username, projectname, 0.0, user.email
12311231
)
12321232
# Copy attributes from base course
12331233
bc = await fetch_course(coursetype)

bases/rsptx/assignment_server_api/routers/instructor.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,6 +1572,7 @@ async def duplicate_assignment_endpoint(
15721572
detail=f"Error duplicating assignment: {str(e)}",
15731573
)
15741574

1575+
15751576
class CreateDatafilePayload(BaseModel):
15761577
filename: str
15771578
main_code: str
@@ -1595,14 +1596,18 @@ async def get_datafiles(
15951596
datafiles_list = []
15961597
for df in datafiles:
15971598
if df is not None:
1598-
datafiles_list.append({
1599-
"id": df.id,
1600-
"acid": df.acid,
1601-
"filename": df.filename,
1602-
"course_id": df.course_id,
1603-
"owner": df.owner,
1604-
"main_code": df.main_code[:100] + "..." if df.main_code and len(df.main_code) > 100 else df.main_code, # Truncate for list view
1605-
})
1599+
datafiles_list.append(
1600+
{
1601+
"id": df.id,
1602+
"acid": df.acid,
1603+
"filename": df.filename,
1604+
"course_id": df.course_id,
1605+
"owner": df.owner,
1606+
"main_code": df.main_code[:100] + "..."
1607+
if df.main_code and len(df.main_code) > 100
1608+
else df.main_code, # Truncate for list view
1609+
}
1610+
)
16061611

16071612
return make_json_response(
16081613
status=status.HTTP_200_OK,
@@ -1616,8 +1621,6 @@ async def get_datafiles(
16161621
)
16171622

16181623

1619-
1620-
16211624
@router.post("/datafile")
16221625
@instructor_role_required()
16231626
@with_course()
@@ -1864,5 +1867,3 @@ async def get_datafile_endpoint(
18641867
status=status.HTTP_400_BAD_REQUEST,
18651868
detail=f"Error fetching datafile: {str(e)}",
18661869
)
1867-
1868-

bases/rsptx/assignment_server_api/routers/student.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,19 @@ def sort_key(assignment):
110110
deadline = assignment.duedate
111111
if timezoneoffset:
112112
deadline = deadline + datetime.timedelta(hours=float(timezoneoffset))
113-
return (deadline < canonical_utcnow(), abs((deadline - canonical_utcnow()).total_seconds()))
113+
return (
114+
deadline < canonical_utcnow(),
115+
abs((deadline - canonical_utcnow()).total_seconds()),
116+
)
114117
else:
115-
return (assignment.duedate < canonical_utcnow(), abs((assignment.duedate - canonical_utcnow()).total_seconds()))
118+
return (
119+
assignment.duedate < canonical_utcnow(),
120+
abs((assignment.duedate - canonical_utcnow()).total_seconds()),
121+
)
116122

117123
# Sort assignments: upcoming assignments first (closest to current date), past due assignments last
118124
now = canonical_utcnow()
119-
assignments.sort(
120-
key=sort_key
121-
)
125+
assignments.sort(key=sort_key)
122126
stats_list = await fetch_all_assignment_stats(course.course_name, user.id)
123127
stats = {}
124128
for s in stats_list:

bases/rsptx/book_server_api/routers/course.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@ def sort_key(assignment):
116116
)
117117

118118
now = canonical_utcnow()
119-
assignments.sort(
120-
key=sort_key
121-
)
119+
assignments.sort(key=sort_key)
122120

123121
stats_list = await fetch_all_assignment_stats(course_name, user.id)
124122
stats = {}

bases/rsptx/book_server_api/routers/rslogging.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,14 @@ async def runlog(request: Request, response: Response, data: LogRunIncoming):
312312

313313
return make_json_response(status=status.HTTP_201_CREATED)
314314

315+
315316
# codetailorlog endpoint
316317
# ---------------
317318
# The :ref:`logCodeTailorEvent` client-side function calls this endpoint to record a CodeTailor puzzle creation
318319
@router.post("/codetailor_log")
319-
async def codetailor_log(request: Request, response: Response, data: LogCodeTailorIncoming):
320+
async def codetailor_log(
321+
request: Request, response: Response, data: LogCodeTailorIncoming
322+
):
320323
"""Make an entry in the CodeTailorParsons table to record a CodeTailor Parsons puzzle creation.
321324
322325
:param request: A FastAPI Request object
@@ -361,7 +364,6 @@ async def codetailor_log(request: Request, response: Response, data: LogCodeTail
361364
return make_json_response(status=status.HTTP_201_CREATED)
362365

363366

364-
365367
async def same_class(user1: AuthUserValidator, user2: str) -> bool:
366368
if user1:
367369
u2 = await fetch_user(user2)

bases/rsptx/interactives/runestone/activecode/js/activecode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export class ActiveCode extends RunestoneBase {
8181
this.parsonspersonalize = $(orig).data("parsonspersonalize"); // CodeTailor: <choose 1 out of two> Allows the instructor to choose personalization level: solution-level or block-and-solution level
8282
this.parsonsexample = $(orig).data("parsonsexample"); // CodeTailor: <choose 1 out of two> Allows the instructor to choose an example Parsons problem or LLM-example (default auto-fill, means the example is generated by LLM)
8383
this.codetailortimestamp = Math.floor(Date.now() / 1000);
84-
this.puzzleScaffoldingDivid = `${this.divid}_codetailor_${this.parsonspersonalize}_${this.sid}_${this.codetailortimestamp}`; // CodeTailor: the div id for the puzzle scaffolding help window
84+
this.puzzleScaffoldingDivid = `${this.divid}_codetailor_${this.parsonspersonalize}_${this.sid}_${this.codetailortimestamp}`; // CodeTailor: the id for the puzzle scaffolding help window - unique for each generated puzzle
8585
this.language = $(orig).data("lang");
8686
this.timelimit = $(orig).data("timelimit");
8787
this.highlightLines = $(orig).data("highlight-lines");

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(
@@ -954,7 +956,9 @@ def grade(config, course, pset, enforce):
954956
)
955957
@click.option("--sample_size", help="Number of courses to sample", default=0)
956958
@click.option("--course_list", help="List of courses to sample", default=None)
957-
@click.option("--preserve_user_ids", is_flag=True, help="Preserve user ids in the datashop export")
959+
@click.option(
960+
"--preserve_user_ids", is_flag=True, help="Preserve user ids in the datashop export"
961+
)
958962
@pass_config
959963
async def datashop(config, basecourse, sample_size, course_list, preserve_user_ids):
960964
"""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: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,10 @@ def _process_single_chapter(sess, db_context, chapter, chap_num, course_name):
679679
res = sess.execute(ins)
680680
return res.inserted_primary_key[0]
681681

682+
682683
import pdb
684+
685+
683686
def _process_subchapters(sess, db_context, chapter, chapid, course_name):
684687
"""Process all subchapters for a given chapter."""
685688
subchap = 0
@@ -695,8 +698,10 @@ def _process_subchapters(sess, db_context, chapter, chapid, course_name):
695698
# at this point (7/28/2025) the only reason for a subsubchapter
696699
# is to have a timed assignment, so we can skip the rest of the
697700
# find all divs with a class of timedAssessment
698-
#pdb.set_trace()
699-
for timed_assessment_div in subchapter.findall(".//div[@class='timedAssessment']"):
701+
# pdb.set_trace()
702+
for timed_assessment_div in subchapter.findall(
703+
".//div[@class='timedAssessment']"
704+
):
700705
_process_single_timed_assignment(
701706
sess,
702707
db_context,
@@ -1010,7 +1015,9 @@ def _process_single_question(
10101015
if qtype == "doenet":
10111016
# rewrite the url in the dbtext to use the course name in the path
10121017
dbtext = re.sub(
1013-
r'(<iframe.*?)src="(.*?.html)"', rf'\1 src="/ns/books/published/{course_name}/\2"', dbtext
1018+
r'(<iframe.*?)src="(.*?.html)"',
1019+
rf'\1 src="/ns/books/published/{course_name}/\2"',
1020+
dbtext,
10141021
)
10151022
optional = "T" if ("optional" in question.attrib or qtype == "datafile") else "F"
10161023
practice = _determine_practice_flag(qtype, el)

components/rsptx/db/crud/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,17 @@
161161
update_question_grade_entry,
162162
)
163163

164-
from .rsfiles import fetch_source_code, update_source_code, update_source_code_sync, fetch_all_datafiles, check_datafile_exists, generate_datafile_acid, fetch_datafile_by_acid, update_datafile, delete_datafile
164+
from .rsfiles import (
165+
fetch_source_code,
166+
update_source_code,
167+
update_source_code_sync,
168+
fetch_all_datafiles,
169+
check_datafile_exists,
170+
generate_datafile_acid,
171+
fetch_datafile_by_acid,
172+
update_datafile,
173+
delete_datafile,
174+
)
165175

166176
from .rslogging import (
167177
count_useinfo_for,

0 commit comments

Comments
 (0)