Skip to content

Commit 436995b

Browse files
committed
Run black on modified files
1 parent 4345aa7 commit 436995b

94 files changed

Lines changed: 1279 additions & 571 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cms/db/util.py

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,29 @@
3131
from sqlalchemy.orm import Query
3232

3333
from cms import ConfigError
34-
from . import SessionGen, Digest, Contest, Participation, Statement, \
35-
Attachment, Task, Manager, Dataset, Testcase, Submission, File, \
36-
SubmissionResult, Executable, UserTest, UserTestFile, UserTestManager, \
37-
UserTestResult, UserTestExecutable, PrintJob, Session
34+
from . import (
35+
SessionGen,
36+
Digest,
37+
Contest,
38+
Participation,
39+
Statement,
40+
Attachment,
41+
Task,
42+
Manager,
43+
Dataset,
44+
Testcase,
45+
Submission,
46+
File,
47+
SubmissionResult,
48+
Executable,
49+
UserTest,
50+
UserTestFile,
51+
UserTestManager,
52+
UserTestResult,
53+
UserTestExecutable,
54+
PrintJob,
55+
Session,
56+
)
3857

3958

4059
logger = logging.getLogger(__name__)
@@ -137,10 +156,13 @@ def ask_for_contest(skip: int | None = None) -> int:
137156
return contest_id
138157

139158

140-
def get_submissions(session: Session, contest_id: int | None = None,
141-
participation_id: int | None = None,
142-
task_id: int | None = None,
143-
submission_id: int | None = None) -> Query:
159+
def get_submissions(
160+
session: Session,
161+
contest_id: int | None = None,
162+
participation_id: int | None = None,
163+
task_id: int | None = None,
164+
submission_id: int | None = None,
165+
) -> Query:
144166
"""Search for submissions that match the given criteria
145167
146168
The submissions will be returned as a list, and the last four
@@ -192,11 +214,14 @@ def get_submissions(session: Session, contest_id: int | None = None,
192214
return query
193215

194216

195-
def get_submission_results(session: Session, contest_id: int | None = None,
196-
participation_id: int | None = None,
197-
task_id: int | None = None,
198-
submission_id: int | None = None,
199-
dataset_id: int | None = None) -> Query:
217+
def get_submission_results(
218+
session: Session,
219+
contest_id: int | None = None,
220+
participation_id: int | None = None,
221+
task_id: int | None = None,
222+
submission_id: int | None = None,
223+
dataset_id: int | None = None,
224+
) -> Query:
200225
"""Search for submission results that match the given criteria
201226
202227
The submission results will be returned as a list, and the last
@@ -279,9 +304,14 @@ def get_datasets_to_judge(task: Task) -> list[Dataset]:
279304

280305

281306
def enumerate_files(
282-
session: Session, contest: Contest | None = None,
283-
skip_submissions=False, skip_user_tests=False, skip_users=False,
284-
skip_print_jobs=False, skip_generated=False) -> set[str]:
307+
session: Session,
308+
contest: Contest | None = None,
309+
skip_submissions=False,
310+
skip_user_tests=False,
311+
skip_users=False,
312+
skip_print_jobs=False,
313+
skip_generated=False,
314+
) -> set[str]:
285315
"""Enumerate all the files (by digest) referenced by the
286316
contest.
287317

cms/grading/Job.py

Lines changed: 90 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,19 @@
3636
import logging
3737
from typing import Self
3838

39-
from cms.db import Dataset, Evaluation, Executable, File, Manager, Submission, \
40-
UserTest, UserTestExecutable, Contest, SubmissionResult, UserTestResult
39+
from cms.db import (
40+
Dataset,
41+
Evaluation,
42+
Executable,
43+
File,
44+
Manager,
45+
Submission,
46+
UserTest,
47+
UserTestExecutable,
48+
Contest,
49+
SubmissionResult,
50+
UserTestResult,
51+
)
4152
from cms.grading.languagemanager import get_language
4253
from cms.service.esoperations import ESOperation
4354

@@ -67,15 +78,23 @@ class Job:
6778
6879
"""
6980

70-
def __init__(self, operation: ESOperation | None = None,
71-
task_type: str | None = None, task_type_parameters: object = None,
72-
language: str | None = None, multithreaded_sandbox: bool = False,
73-
shard: int | None = None, keep_sandbox: bool = False,
74-
sandboxes: list[str] | None = None, info: str | None = None,
75-
success: bool | None = None, text: list[str] | None = None,
76-
files: dict[str, File] | None = None,
77-
managers: dict[str, Manager] | None = None,
78-
executables: dict[str, Executable] | None = None):
81+
def __init__(
82+
self,
83+
operation: ESOperation | None = None,
84+
task_type: str | None = None,
85+
task_type_parameters: object = None,
86+
language: str | None = None,
87+
multithreaded_sandbox: bool = False,
88+
shard: int | None = None,
89+
keep_sandbox: bool = False,
90+
sandboxes: list[str] | None = None,
91+
info: str | None = None,
92+
success: bool | None = None,
93+
text: list[str] | None = None,
94+
files: dict[str, File] | None = None,
95+
managers: dict[str, Manager] | None = None,
96+
executables: dict[str, Executable] | None = None,
97+
):
7998
"""Initialization.
8099
81100
operation: the operation.
@@ -192,7 +211,9 @@ def import_from_dict(cls, data: dict) -> Self:
192211
return cls(**data)
193212

194213
@staticmethod
195-
def from_operation(operation: ESOperation, object_: Submission | UserTest, dataset: Dataset) -> "Job":
214+
def from_operation(
215+
operation: ESOperation, object_: Submission | UserTest, dataset: Dataset
216+
) -> "Job":
196217
"""Produce the job for the operation in the argument.
197218
198219
Return the Job object that has to be sent to Workers to have
@@ -245,22 +266,25 @@ class CompilationJob(Job):
245266
246267
"""
247268

248-
def __init__(self, operation: ESOperation | None = None,
249-
task_type: str | None = None,
250-
task_type_parameters: object = None,
251-
shard: int | None = None,
252-
keep_sandbox: bool = False,
253-
sandboxes: list[str] | None = None,
254-
info: str | None = None,
255-
language: str | None = None,
256-
multithreaded_sandbox: bool = False,
257-
files: dict[str, File] | None = None,
258-
managers: dict[str, Manager] | None = None,
259-
success: bool | None = None,
260-
compilation_success: bool | None = None,
261-
executables: dict[str, Executable] | None = None,
262-
text: list[str] | None = None,
263-
plus: dict | None = None):
269+
def __init__(
270+
self,
271+
operation: ESOperation | None = None,
272+
task_type: str | None = None,
273+
task_type_parameters: object = None,
274+
shard: int | None = None,
275+
keep_sandbox: bool = False,
276+
sandboxes: list[str] | None = None,
277+
info: str | None = None,
278+
language: str | None = None,
279+
multithreaded_sandbox: bool = False,
280+
files: dict[str, File] | None = None,
281+
managers: dict[str, Manager] | None = None,
282+
success: bool | None = None,
283+
compilation_success: bool | None = None,
284+
executables: dict[str, Executable] | None = None,
285+
text: list[str] | None = None,
286+
plus: dict | None = None,
287+
):
264288
"""Initialization.
265289
266290
See base class for the remaining arguments.
@@ -288,7 +312,9 @@ def export_to_dict(self) -> dict:
288312
return res
289313

290314
@staticmethod
291-
def from_submission(operation: ESOperation, submission: Submission, dataset: Dataset) -> "CompilationJob":
315+
def from_submission(
316+
operation: ESOperation, submission: Submission, dataset: Dataset
317+
) -> "CompilationJob":
292318
"""Create a CompilationJob from a submission.
293319
294320
operation: a COMPILATION operation.
@@ -346,7 +372,9 @@ def to_submission(self, sr: SubmissionResult):
346372
sr.executables.set(executable)
347373

348374
@staticmethod
349-
def from_user_test(operation: ESOperation, user_test: UserTest, dataset: Dataset) -> "CompilationJob":
375+
def from_user_test(
376+
operation: ESOperation, user_test: UserTest, dataset: Dataset
377+
) -> "CompilationJob":
350378
"""Create a CompilationJob from a user test.
351379
352380
operation: a USER_TEST_COMPILATION operation.
@@ -449,29 +477,32 @@ class EvaluationJob(Job):
449477
only_execution, get_output.
450478
451479
"""
452-
def __init__(self, operation: ESOperation | None = None,
453-
task_type: str | None = None,
454-
task_type_parameters: object = None,
455-
shard: int | None = None,
456-
keep_sandbox: bool = False,
457-
sandboxes: list[str] | None = None,
458-
info: str | None = None,
459-
language: str | None = None,
460-
multithreaded_sandbox: bool = False,
461-
files: dict[str, File] | None = None,
462-
managers: dict[str, Manager] | None = None,
463-
executables: dict[str, Executable] | None = None,
464-
input: str | None = None,
465-
output: str | None = None,
466-
time_limit: float | None = None,
467-
memory_limit: int | None = None,
468-
success: bool | None = None,
469-
outcome: str | None = None,
470-
text: list[str] | None = None,
471-
user_output: str | None = None,
472-
plus: dict | None = None,
473-
only_execution: bool | None = False,
474-
get_output: bool | None = False):
480+
def __init__(
481+
self,
482+
operation: ESOperation | None = None,
483+
task_type: str | None = None,
484+
task_type_parameters: object = None,
485+
shard: int | None = None,
486+
keep_sandbox: bool = False,
487+
sandboxes: list[str] | None = None,
488+
info: str | None = None,
489+
language: str | None = None,
490+
multithreaded_sandbox: bool = False,
491+
files: dict[str, File] | None = None,
492+
managers: dict[str, Manager] | None = None,
493+
executables: dict[str, Executable] | None = None,
494+
input: str | None = None,
495+
output: str | None = None,
496+
time_limit: float | None = None,
497+
memory_limit: int | None = None,
498+
success: bool | None = None,
499+
outcome: str | None = None,
500+
text: list[str] | None = None,
501+
user_output: str | None = None,
502+
plus: dict | None = None,
503+
only_execution: bool | None = False,
504+
get_output: bool | None = False,
505+
):
475506
"""Initialization.
476507
477508
See base class for the remaining arguments.
@@ -525,7 +556,9 @@ def export_to_dict(self) -> dict:
525556
return res
526557

527558
@staticmethod
528-
def from_submission(operation: ESOperation, submission: Submission, dataset: Dataset) -> "EvaluationJob":
559+
def from_submission(
560+
operation: ESOperation, submission: Submission, dataset: Dataset
561+
) -> "EvaluationJob":
529562
"""Create an EvaluationJob from a submission.
530563
531564
operation: an EVALUATION operation.
@@ -590,7 +623,9 @@ def to_submission(self, sr: SubmissionResult):
590623
testcase=sr.dataset.testcases[self.operation.testcase_codename])]
591624

592625
@staticmethod
593-
def from_user_test(operation: ESOperation, user_test: UserTest, dataset: Dataset) -> "EvaluationJob":
626+
def from_user_test(
627+
operation: ESOperation, user_test: UserTest, dataset: Dataset
628+
) -> "EvaluationJob":
594629
"""Create an EvaluationJob from a user test.
595630
596631
operation: an USER_TEST_EVALUATION operation.

cms/grading/ParameterTypes.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
from jinja2 import Markup, Template
3333
import typing
34+
3435
if typing.TYPE_CHECKING:
3536
from tornado.web import RequestHandler
3637

@@ -203,7 +204,9 @@ class ParameterTypeCollection(ParameterType):
203204
</table>
204205
""")
205206

206-
def __init__(self, name, short_name, description, subparameters: list[ParameterType]):
207+
def __init__(
208+
self, name, short_name, description, subparameters: list[ParameterType]
209+
):
207210
"""Initialization.
208211
209212
subparameters: list of types of each sub-parameter.

0 commit comments

Comments
 (0)