Skip to content

Commit

Permalink
Removed unused imports + small code style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
geordi authored and Kobzol committed Apr 11, 2024
1 parent 9d075a7 commit 6edd55f
Show file tree
Hide file tree
Showing 15 changed files with 20 additions and 38 deletions.
10 changes: 2 additions & 8 deletions common/admin.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import os

from django.contrib import admin
import common.models as models
from django.contrib.auth.models import User, Group
from django.contrib.auth.admin import UserAdmin
from django.db.models import TextField
from django import forms
from django.core.exceptions import ValidationError
from django.contrib.auth.models import User

from web.task_utils import load_readme, process_markdown
import common.models as models
import common.utils


Expand Down
9 changes: 4 additions & 5 deletions common/inbus/inbus.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import urllib.parse

from django.core.cache import cache
from typing import List

import serde
Expand All @@ -23,7 +22,7 @@ def person_by_login(login: str) -> dto.PersonSimple | None:
return None

person_simple = dto.PersonSimple(login=person_json["login"].upper(), first_name=person_json.get('firstName', ''), second_name=person_json.get('secondName', ''),
full_name=person_json.get('fullName', ''), email=person_json.get('email', ''))
full_name=person_json.get('fullName', ''), email=person_json.get('email', ''))

return person_simple

Expand All @@ -47,9 +46,9 @@ def subject_versions(department_id: dto.DepartmentId = 386) -> List[dto.SubjectV
subject_guarantee = serde.from_dict(dto.Person, subject_json['guarantee'])
subject_version_guarantee = serde.from_dict(dto.Person, subject_version_json['guarantee'])
subject = dto.Subject(subjectId=subject_json['subjectId'], code=subject_json['code'], abbrev=subject_json['abbrev'],
title=subject_json['title'], guarantee=subject_guarantee)
subject_version = dto.SubjectVersion(subjectVersionId=subject_version_json['subjectVersionId'], subject=subject,
subjectVersionCompleteCode=subject_version_json['subjectVersionCompleteCode'], guarantee=subject_version_guarantee)
title=subject_json['title'], guarantee=subject_guarantee)
subject_version = dto.SubjectVersion(subjectVersionId=subject_version_json['subjectVersionId'], subject=subject,
subjectVersionCompleteCode=subject_version_json['subjectVersionCompleteCode'], guarantee=subject_version_guarantee)

subject_versions.append(subject_version)

Expand Down
6 changes: 3 additions & 3 deletions common/inbus/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ def is_response_ok_or_new_token_(response: requests.Response) -> bool:

def inbus_request(url, params: Dict = None) -> requests.Response | None:
if params is None:
params={}
params = {}
token = inbus_token()
headers = {
"Authorization": f"Bearer {token['access_token']}",
"Accept" : "application/json",
"Accept-Language" : "cz"
"Accept": "application/json",
"Accept-Language": "cz"
}

try:
Expand Down
1 change: 0 additions & 1 deletion common/management/commands/fill_user_info.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.core.management.base import BaseCommand
from django.conf import settings
from django.contrib.auth.models import User
from django.db.models import Q
from common.utils import inbus_search_user
Expand Down
2 changes: 1 addition & 1 deletion common/management/commands/import_students.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.core.management.base import BaseCommand, CommandError
from django.core.management.base import BaseCommand
from common.bulk_import import BulkImport

class Command(BaseCommand):
Expand Down
4 changes: 1 addition & 3 deletions common/management/commands/transfer_submits.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import os
import re
import shutil

from django.core.management.base import BaseCommand

from common.models import AssignedTask, Class, Submit


class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument('assignment_id')
Expand Down Expand Up @@ -39,4 +38,3 @@ def handle(self, *args, **opts):
submit.save()

print(submit, c, new_assigned_task, submits)

2 changes: 1 addition & 1 deletion common/moss/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def moss_check_task(task_id: int, notify_teacher: bool, submit_limit: int | None
logger.addHandler(log_handler)
logger.setLevel(logging.INFO)

logger.info(f"Plagiarism checking started")
logger.info("Plagiarism checking started")
counters = {lang: 0 for lang in ALLOWED_EXTENSIONS.values()}

url = None
Expand Down
2 changes: 1 addition & 1 deletion evaluator/images/clang-tidy/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def build(self, path):
cmd = [
"clang-tidy",
'-extra-arg=-std=c++17',
f"--export-fixes=/tmp/fixes.yaml",
"--export-fixes=/tmp/fixes.yaml",
f"--checks={','.join(checks)}",
*files
]
Expand Down
4 changes: 2 additions & 2 deletions evaluator/images/gcc/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
import html
import subprocess
import os
import re
import shlex
import json
from collections import defaultdict


# TODO: replace with shlex.join on python3.8
def shlex_join(split_command):
return ' '.join(shlex.quote(arg) for arg in split_command)


def cmd_run(cmd, out, show_cmd=None, env=None):
if not show_cmd:
show_cmd = cmd
Expand Down
4 changes: 2 additions & 2 deletions evaluator/images/run/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import subprocess
import html
import base64
from io import StringIO
import glob
import magic

Expand All @@ -18,7 +17,8 @@
'image/svg+xml',
]

DEFAULT_TIMEOUT=5
DEFAULT_TIMEOUT = 5


def display(patterns, out, delete=False):
for pattern in patterns:
Expand Down
2 changes: 1 addition & 1 deletion evaluator/pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from common.utils import points_to_color
from .results import TestResult
from . import testsets
from kelvin.settings import BASE_DIR

from .utils import parse_human_size, copyfile

Expand Down Expand Up @@ -39,6 +38,7 @@
},
}


def create_docker_cmd(evaluation, image, additional_args=None, cmd=None, limits=None, env=None):
if not limits:
limits = {}
Expand Down
2 changes: 0 additions & 2 deletions web/apps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import logging

from django.apps import AppConfig

class WebConfig(AppConfig):
Expand Down
6 changes: 2 additions & 4 deletions web/views/common.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import hashlib

from django.contrib.auth.decorators import login_required, user_passes_test
from django.contrib.auth.decorators import login_required
from django.shortcuts import render
from django.utils.crypto import get_random_string
from django.contrib.auth.hashers import make_password
from django.conf import settings
from django.urls import reverse
from api.models import UserToken
Expand All @@ -12,6 +9,7 @@
from common.utils import is_teacher
from api.backends import hash_token


@login_required()
def index(request):
if is_teacher(request.user):
Expand Down
3 changes: 0 additions & 3 deletions web/views/notification.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from django.contrib.auth.decorators import login_required
from django.shortcuts import redirect
from django.http import JsonResponse
from django.forms.models import model_to_dict
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import SuspiciousOperation
from django.views.decorators.csrf import csrf_exempt
from common.models import Comment
Expand Down
1 change: 0 additions & 1 deletion web/views/teacher.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import shutil
import tarfile
import tempfile
import traceback
from collections import OrderedDict
from typing import Dict, List, Tuple

Expand Down

0 comments on commit 6edd55f

Please sign in to comment.