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

Add Monkeytype and Poe the Poet plugin for Poetry #1731

Merged
merged 33 commits into from
Sep 12, 2024

Conversation

whabanks
Copy link
Contributor

@whabanks whabanks commented Dec 1, 2023

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

@whabanks whabanks requested a review from jimleroyer December 4, 2023 14:48
@whabanks whabanks removed the request for review from jimleroyer December 13, 2023 20:28
@whabanks whabanks marked this pull request as draft December 13, 2023 20:28
whabanks and others added 3 commits January 30, 2024 08:36
- Added monkeytype config
- Specified code filter so we only trace packages and modules we actually want traced
@whabanks whabanks changed the title Add monkeytype and poe the poet plugin for poetry Add Monkeytype and Poe the Poet plugin for Poetry Apr 19, 2024
@whabanks whabanks marked this pull request as ready for review May 28, 2024 14:14
Copy link

Copy link

@whabanks whabanks merged commit 4661f79 into main Sep 12, 2024
10 checks passed
@whabanks whabanks deleted the experiment-poe-monkeytype branch September 12, 2024 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants