Skip to main content

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, output=4)
@test_case(-2, 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:

  1. Clone the repo: git clone git@github.com:nihilistkitten/aga.git && cd aga.
  2. Install poetry.
  3. Install dependencies: poetry install.
  4. 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.
  5. 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:

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:

  • black, a highly opinionated code formatter.
  • isort, an import sorter.

To run both formatters, run nox -rs fmt. This is not run by default runs of nox.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aga-0.2.0.tar.gz (11.5 kB view hashes)

Uploaded Source

Built Distribution

aga-0.2.0-py3-none-any.whl (11.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page