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

Invalid usage of NoReturn #105

Merged
merged 1 commit into from
Aug 11, 2021
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
6 changes: 3 additions & 3 deletions pybryt/annotations/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from abc import ABC, abstractmethod
from collections import OrderedDict
from typing import Any, Dict, List, NoReturn, Optional, Tuple
from typing import Any, Dict, List, Optional, Tuple


_TRACKED_ANNOTATIONS = []
Expand Down Expand Up @@ -67,7 +67,7 @@ def __repr__(self):
ret = f"pybryt.{self.__class__.__name__}"
return ret

def _track(self) -> NoReturn:
def _track(self) -> None:
"""
Tracks this annotation in ``_TRACKED_ANNOTATIONS`` and updates ``_GROUP_INDICES`` with the
index of the annotation if ``self.group`` is present. If the annotation has children
Expand Down Expand Up @@ -106,7 +106,7 @@ def get_tracked_annotations() -> List["Annotation"]:
return _TRACKED_ANNOTATIONS

@staticmethod
def reset_tracked_annotations() -> NoReturn:
def reset_tracked_annotations() -> None:
"""
Resets the list of tracked annotations and the mapping of group names to indices in that
list.
Expand Down
6 changes: 3 additions & 3 deletions pybryt/annotations/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__all__ = ["Collection"]

from typing import Any, Dict, List, NoReturn, Tuple
from typing import Any, Dict, List, Tuple

from .annotation import Annotation, AnnotationResult

Expand Down Expand Up @@ -104,7 +104,7 @@ def to_dict(self) -> Dict[str, Any]:
})
return d

def add(self, annotation: Annotation) -> NoReturn:
def add(self, annotation: Annotation) -> None:
"""
Adds an annotation to this collection.

Expand All @@ -121,7 +121,7 @@ def add(self, annotation: Annotation) -> NoReturn:
except ValueError: # pragma: no cover
pass

def remove(self, annotation: Annotation) -> NoReturn:
def remove(self, annotation: Annotation) -> None:
"""
Removes an annotation from this collection.

Expand Down
16 changes: 8 additions & 8 deletions pybryt/integrations/otter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from otter.plugins import AbstractOtterPlugin
from otter.test_files import GradingResults
from otter.utils import get_source
from typing import Any, Dict, List, NoReturn, Optional, Union
from typing import Any, Dict, List, Optional, Union

from .. import ReferenceImplementation, StudentImplementation
from ..execution import NBFORMAT_VERSION
Expand All @@ -30,7 +30,7 @@ class OtterPlugin(AbstractOtterPlugin):
_generate_report = None
_student_impl = None

def during_assign(self, assignment: Assignment) -> NoReturn:
def during_assign(self, assignment: Assignment) -> None:
"""
This event runs during ``otter assign`` and compiles the list of references indicated in the
plugin config, placing the pickled reference implementations in the otuput directories. The
Expand All @@ -55,7 +55,7 @@ def during_assign(self, assignment: Assignment) -> NoReturn:
stp = assignment.result / 'student' / ref_fn
shutil.copy(str(agp), str(stp))

def during_generate(self, otter_config: Dict[str, Any], assignment: Assignment) -> NoReturn:
def during_generate(self, otter_config: Dict[str, Any], assignment: Assignment) -> None:
"""
This event runs during ``otter generate`` and, if ``otter assign`` was run, adds the cached
reference implementations from that run or compiles the indicated references if it was not
Expand Down Expand Up @@ -88,7 +88,7 @@ def during_generate(self, otter_config: Dict[str, Any], assignment: Assignment)
if assignment is not None:
os.chdir(cwd)

def _generate_impl_report(self, refs: List[ReferenceImplementation], group: Optional[str] = None) -> NoReturn:
def _generate_impl_report(self, refs: List[ReferenceImplementation], group: Optional[str] = None) -> None:
"""
Generates and caches a student implementation from the submission path being graded as well
as a report of what reference(s) were satisfied, if any, and the messages received from
Expand Down Expand Up @@ -124,7 +124,7 @@ def _generate_impl_report(self, refs: List[ReferenceImplementation], group: Opti
self._generated_report = report
self._student_impl = stu

def _cache_student_impl(self, results: GradingResults, stu: StudentImplementation) -> NoReturn:
def _cache_student_impl(self, results: GradingResults, stu: StudentImplementation) -> None:
"""
Caches the student implementation object as a base-64-encoded string in the grading results
to be retrieved outside of the grading process.
Expand All @@ -139,7 +139,7 @@ def _cache_student_impl(self, results: GradingResults, stu: StudentImplementatio
results.set_plugin_data(self.IMPORTABLE_NAME, data)

@classmethod
def _remove_plugin_calls(cls, nb: Dict[str, Any]) -> NoReturn:
def _remove_plugin_calls(cls, nb: Dict[str, Any]) -> None:
"""
Removes calls to this Otter plugin from a notebook to ensure that a loop isn't created.
Modifies the notebook in-place.
Expand All @@ -155,7 +155,7 @@ def _remove_plugin_calls(cls, nb: Dict[str, Any]) -> NoReturn:
source[i] = "# " + source[i]
cell["source"] = "\n".join(source)

def from_notebook(self, *ref_paths: str, group: Optional[str] = None) -> NoReturn:
def from_notebook(self, *ref_paths: str, group: Optional[str] = None) -> None:
"""
This event runs when ``otter.Notebook.run_plugin`` is called to execute this plugin. It
attempts to force-save the notebook and then loads the references indicated and generates
Expand Down Expand Up @@ -213,7 +213,7 @@ def before_execution(self, submission: Dict[str, Any]) -> dict:
self._remove_plugin_calls(submission)
return submission

def after_grading(self, results: GradingResults) -> NoReturn:
def after_grading(self, results: GradingResults) -> None:
"""
Generates an implementation report and caches the student implementation in the grading
results.
Expand Down
2 changes: 1 addition & 1 deletion pybryt/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from copy import deepcopy
from textwrap import indent
from typing import Any, Dict, List, NoReturn, Optional, Tuple, Union
from typing import Any, Dict, List, Optional, Tuple, Union

from .annotations import Annotation, AnnotationResult
from .utils import get_stem, notebook_to_string, Serializable
Expand Down
4 changes: 2 additions & 2 deletions pybryt/student.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from glob import glob
from multiprocessing import Process, Queue
from types import FrameType
from typing import Any, Dict, List, NoReturn, Optional, Tuple, Union
from typing import Any, Dict, List, Optional, Tuple, Union

from .execution import (
create_collector, execute_notebook, _get_tracing_frame, NBFORMAT_VERSION, tracing_off,
Expand Down Expand Up @@ -80,7 +80,7 @@ def __init__(

self._execute(timeout, addl_filenames=addl_filenames, output=output)

def _execute(self, timeout: Optional[int], addl_filenames: List[str] = [], output: Optional[str] = None) -> NoReturn:
def _execute(self, timeout: Optional[int], addl_filenames: List[str] = [], output: Optional[str] = None) -> None:
"""
Executes the notebook ``self.nb``.

Expand Down
8 changes: 4 additions & 4 deletions pybryt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import nbformat

from abc import ABC, abstractmethod
from typing import Any, List, NoReturn, Optional, Union
from typing import Any, List, Optional, Union
from IPython import get_ipython
from IPython.display import publish_display_data

Expand All @@ -30,7 +30,7 @@ def pickle_and_hash(obj: Any) -> str:
return hashlib.sha512(s).hexdigest()


def filter_picklable_list(lst: List[Any]) -> NoReturn:
def filter_picklable_list(lst: List[Any]) -> None:
"""
Removes all elements from a list that cannot be pickled with ``dill``.

Expand Down Expand Up @@ -127,7 +127,7 @@ def save_notebook(filename, timeout=10):
return curr != md5


def get_stem(fp):
def get_stem(fp) -> str:
"""
Returns the stem of a filepath.

Expand All @@ -153,7 +153,7 @@ def _default_dump_dest(self) -> str:
"""
... # pragma: no cover

def dump(self, dest: Optional[str] = None) -> NoReturn:
def dump(self, dest: Optional[str] = None) -> None:
"""
Pickles this object to a file.

Expand Down