notification-admin
notification-admin copied to clipboard
Add Monkeytype and Poe the Poet plugin for Poetry
Summary | Résumé
This is an experimental PR that adds monkeytype
and the Poetry plugin Poe the Poet to the project.
MonkeyType
Monkeytype collects runtime types of function arguments and return values, and can automatically generate stub files or even add draft type annotations directly to your Python code based on the types collected at runtime.
While it is very useful for automating the process of type annotating Python code bases, it is somewhat cumbersome to work with manually.
Poe the Poet
Enter Poe the Poet, a task runner similar to make
that provides a simple way to define project tasks directly in pyproject.toml
.
Leveraging features like composite tasks and graphs we can create a rich, fully documented ecosystem of project specific tasks.
Since all poe
tasks are run from within the Poetry virtual env by default, we no longer need to ask ourselves the question "Do I need poetry run...
in front of this command?", nor would we need poetry run
in front of nearly every command in our makefile
.
This PR leverages the plugin to create a basic suite of tasks to simplify using Monkeytype
. Just run poe
or poe --help
to list fully documented tasks:
CONFIGURED TASKS
trace-tests Runs a Python test file through MonkeyType, generating a record of type annotation traces. Traces are stored in monkeytype.sqlite3
-p, --path Path to the test file to run. /tests/app/ can be omitted. e.g. poe trace-tests -p main/test_contact.py
-m, --method Name of the test method to execute and trace
list-traces Lists all traces awaiting application from monkeytype.sqlite3
apply-annotations Applies ALL type annotations generated by trace-tests.
For a deep dive into Poe the Poet check out the wiki page I put together