aga grades assignments
Project description
aga (aga grades assignments) is a tool for automatically checking the correctness of python code against known-correct solutions.
Usage
In square.py
(or any file), write:
from aga import problem, test_case
@test_case(-3)
@test_case(100)
@test_case(2, aga_output=4)
@test_case(-2, aga_output=4)
@problem()
def square(x: int) -> int:
"""Square x."""
return x * x
Then run aga gen square
from the directory with square.py
. This will generate a ZIP
file suitable for upload to gradescope.
More user-facing documentation is WIP.
Development
Setup
To set up the development environment:
- Clone the repo:
git clone git@github.com:nihilistkitten/aga.git && cd aga
. - Install poetry.
- Install dependencies:
poetry install
. - Install a python3.6 interpreter (I assume you already have the most recent
python
). This is necessary for testing against the Gradescope environment. While you can just download it from the above-linked website, I recommend pyenv for managing multiple python versions. - Activate the development environment:
poetry shell
.
I encourage you to set up integration between our dev tools and your editor, but it's not strictly necessary; you can use them as you please, from their CLIs or (I suppose) not at all. Regardless, the environment includes python-lsp-server, which I personally use for this purpose, and can be used via lsp-mode
in emacs, atom-languageclient
in atom, or the built-in lsp support in neovim and vscode.
Nox
The tool nox runs tooling in virtualized environments, which is especially useful for running tests against python3.6 for Gradescope. To both run tests and lints, run nox -r
(-r
prevents nox from reinstalling the environments across multiple runs, which saves significant time.)
Testing
Testing depends on pytest. To run tests, simply run pytest
from within the poetry shell. To run tests in python 3.9 and 3.6 via nox, run nox -rs test
.
Code coverage information can be generated by pytest --cov
. This happens by default in nox runs.
Linting
A number of static analysis tools are available in the development environment:
- mypy, a static type analysis tool.
- pylint, a general-purpose linter.
- flake8, a highly modular linter.
- flake8-black, a code formatting checker.
- flake8-bugbear, which makes
flake8
stricter.
- pydocstyle, a documentation linter.
These tend to be quite strict, but after a while you'll get used to them, and they help write much better code.
To run all lints across python 3.6 and 3.9, run nox -rs lint
.
Formatting
We use two tools to enforce a uniform code style:
To run both formatters, run nox -rs fmt
. This is not run by default runs of nox.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.