This repo contains a few snippets that allow one to use apply MonkeyType onto modules within PyCharm by using the ExternalTools functionality within PyCharm.
This was created in order to quickly be able to perform the following:
- Infer and add types/annotations onto methods that are not typed properly
- Note: I currently don't know how to use stubs to generate patches to apply, if someone knows, please do leave a comment, so I can apply it :)!
- Use the recently generated/corrected method return types and signatures to create patches which contain also contain reformatted docstrings
- This external tool makes a backup in the same folder of the associated script/module/.py file being imported from the script the external tool is running on.
- I'm not sure how this external tool reacts to improperly formatted .py files, or folders where one does not have write permissions.
- Pyment re-formats to
reST
docstrings, but you can change this and other Pyment settings inmonkeytype_run.py
to fit your needs. - Delete the patches found in the patches folder, and run the test
test_monkeytype_run.py
if you're interested in testing/stepping through the code.- You can also test the pycharm external tool by running it on the modules found in this repo.
-
Clone repo
-
Install the following dependencies:
- monkeytype
- black
- isort
- pyment (use the github version since the pypi version isn't updated)
- pytest
-
Follow steps in images below
-
Select Project Directory the script is a part of (this will contain your monkeytype.sqlite3 db, and your script/package/module must be found somewhere (nested or not) in this folder)
- Example output shown above
- Patch for import dependency shown in red on left panel above