Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typehints to all_sources and is_source_valid #454

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import re
import logging

from typing import List

from django.utils import timezone

from django.db import models
Expand Down Expand Up @@ -248,7 +250,7 @@ def source_path(self, name):
def pipeline_path(self):
return re.sub(r'^submits/', 'submit_results/', str(self.dir()))

def all_sources(self):
def all_sources(self) -> List[SourcePath]:
sources = []
offset = len(self.dir()) + 1
for root, dirs, files in os.walk(self.dir()):
Expand Down
4 changes: 2 additions & 2 deletions common/moss/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from networkx.drawing.nx_agraph import write_dot
from notifications.signals import notify

from common.models import AssignedTask, Class, Submit, Task
from common.models import AssignedTask, Class, Submit, Task, SourcePath
from kelvin.settings import BASE_DIR

MAX_FILE_SIZE = 128 * 1024
Expand Down Expand Up @@ -54,7 +54,7 @@ def check_file_size(path: str) -> bool:
return 0 < os.path.getsize(path) <= MAX_FILE_SIZE


def is_source_valid(logger, source) -> bool:
def is_source_valid(logger, source: SourcePath) -> bool:
if not is_ext_allowed(source.virt):
logger.warning(f"Skipping file {source.virt} because of extension")
return False
Expand Down
Loading