grader.checks package
Submodules
grader.checks.abstract_check module
Module containing a class representing an abstract check. Each check should inherit from this class.
- class grader.checks.abstract_check.AbstractCheck(name: str, project_root: str, is_venv_required: bool = False)[source]
Bases:
ABC,Generic[T]Each check has a name and a project root path.
- static is_running_within_venv() bool[source]
Determine if the check is running within a virtual environment.
- Returns:
True if running within a virtual environment, False otherwise.
- Return type:
bool
- property name: str
Get the name of the check.
- Returns:
The name of the check.
- Return type:
str
- abstract run() CheckResult[T][source]
Main method that executes the check.
- Returns:
The result of the check.
- Return type:
Optional[T]
- exception grader.checks.abstract_check.CheckError[source]
Bases:
ExceptionCustom exception for check errors.
- class grader.checks.abstract_check.CheckResult(name: str, result: T)[source]
Bases:
Generic[T]Class representing the result of a check.
- name: str
- result: T
- class grader.checks.abstract_check.NonScoredCheck(name: str, project_root: str, is_fatal: bool, is_venv_requred: bool = False)[source]
Bases:
AbstractCheck[bool]Non-scored checks do not have a maximum amount of points.
- property is_fatal: bool
True if the check failing is fatal, False otherwise. :rtype: bool
- Type:
returns
- class grader.checks.abstract_check.NonScoredCheckResult(name: str, result: T)[source]
Bases:
CheckResult[bool]Class representing the result of a non-scored check.
- class grader.checks.abstract_check.ScoredCheck(name: str, max_points: int, project_root: str, is_venv_requred: bool = False)[source]
Bases:
AbstractCheck[float]Each scored check has a maximum amount of points.
- property max_points: int
The maximum amount of points that can be achieved by the check. :rtype: int
- Type:
returns
- class grader.checks.abstract_check.ScoredCheckResult(name: str, result: T, max_score: int)[source]
Bases:
CheckResult[T]Class representing the result of a scored check.
- max_score: int
grader.checks.checks_factory module
grader.checks.coverage_check module
Module containing the unit test code coverage check.
- class grader.checks.coverage_check.CoverageCheck(name: str, project_root: str, max_points: int, is_venv_required: bool)[source]
Bases:
ScoredCheckThe Coverage check class.
- run() ScoredCheckResult[source]
Run the coverage check on the project.
- Returns:
The score from the coverage check.
- Return type:
float
grader.checks.pylint_check module
Module containing the pylint check. It uses the pylint python library directly to run the check.
- class grader.checks.pylint_check.PylintCheck(name: str, project_root: str, max_points: int, is_venv_required: bool)[source]
Bases:
ScoredCheckThe Pylint check class.
- run() ScoredCheckResult[source]
Run the pylint check on the project. First, find all python files in the project, then create a custom reporter (to suppress all output). Run the pylint check itself and map the score within the desired bounds.
- Returns:
The score from the pylint check.
- Return type:
float
- class grader.checks.pylint_check.PylintCustomReporter[source]
Bases:
TextReporterCustom reported to suppress all output. By default, the pylint library shows everything on the stdout.
- display_messages(layout) None[source]
Hook for displaying the messages of the reporter.
This will be called whenever the underlying messages needs to be displayed. For some reporters, it probably doesn’t make sense to display messages as soon as they are available, so some mechanism of storing them could be used. This method can be implemented to display them after they’ve been aggregated.
grader.checks.requirements_check module
Module containing the requirements.txt check. It checks if requirements.txt exists in the project root.
- class grader.checks.requirements_check.RequirementsCheck(name: str, project_root: str, max_points: int, is_venv_required: bool)[source]
Bases:
ScoredCheckThe requirements.txt check class.
- run() ScoredCheckResult[source]
Run the requirements check on the project. Check if requirements.txt exists in the project root - the score is either 0 or full points. :return: The score from the requirements.txt check :rtype: float
grader.checks.type_hints_check module
Module containing the type hints check. It calls mypy as a subprocess to generate a report and then read from the report.
- class grader.checks.type_hints_check.TypeHintsCheck(name: str, project_root: str, max_points: int, is_venv_required: bool)[source]
Bases:
ScoredCheckThe TypeHints check class.
- run() ScoredCheckResult[source]
Run the mypy check on the project.
First, find all python files in the project, then run mypy on all files with the special config. Mypy then generates a report with the amount of lines with type hints and the total amount of lines.
The first line in the report contains the values for all files. The line contains a lot of stuff, we just need the type-hinted lines and the total amount of lines.
- Returns:
The score from the mypy check.
- Return type:
float