Skip to content

Commit

Permalink
Fix mypy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
james-perretta committed Apr 29, 2024
1 parent 9b8ee8e commit 7018e2d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions autograder/core/models/copy_project_and_course.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ def do_copy(self) -> Project:
return self._new_project

def _copy_instructor_files(self) -> None:
assert self._new_project is not None

for instructor_file in self._project_to_copy.instructor_files.all():
with instructor_file.open('rb') as f:
new_file = InstructorFile.objects.validate_and_create(
Expand Down
6 changes: 4 additions & 2 deletions autograder/core/models/project/instructor_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from typing import IO, Any, AnyStr, BinaryIO, Dict, Literal, TextIO, Tuple, overload

from django.core import exceptions
from django.core.files import File
from django.db import models, transaction
from django.db.models.fields.files import File

import autograder.core.constants as const
import autograder.core.utils as core_ut
Expand All @@ -27,7 +27,9 @@ def _validate_filename(file_obj: File) -> None:


class InstructorFileManager(AutograderModelManager['InstructorFile']):
def validate_and_create(self, *, file_obj: File, project: Project) -> InstructorFile:
def validate_and_create( # type: ignore [override]
self, *, file_obj: File, project: Project
) -> InstructorFile:
if file_obj.size > const.MAX_INSTRUCTOR_FILE_SIZE:
raise exceptions.ValidationError(
{'content': 'Instructor files cannot be bigger than {} bytes'.format(
Expand Down

0 comments on commit 7018e2d

Please sign in to comment.