auto-type-annotate
automatically add annotations to untyped python code!
installation
pip install auto-type-annotate
usage
this tool is intented to help you automatically add annotations while gradually typing a code base!
there's a few pre-requisites you'll need to do in order to use the tool successfully
first you'll need to make your codebase pass mypy with the following settings
enabled:
check_untyped_defs = true: this is needed to analyze types in functions we'd like to automatically typelocal_partial_types = true: this is a setting forced bydmypy-- which we'll be using to generate typing suggestions
you can check whether you're "ready" to use this by running the following:
dmypy stop
dmypy run
it should look something like:
$ dmypy stop
Daemon stopped
$ dmypy run
Daemon started
Success: no issues found in 6839 source files
once that passes -- and dmypy is still running: use the tool on whatever
files you'd like to improve!
for instance after:
auto-type-annotate \
--application-directories .:src \
src/sentry/api/authentication.py
$ git diff
diff --git a/src/sentry/api/authentication.py b/src/sentry/api/authentication.py
index ec0526b9f62..ac797d136f5 100644
--- a/src/sentry/api/authentication.py
+++ b/src/sentry/api/authentication.py
@@ -86,7 +86,7 @@ class AuthenticationSiloLimit(SiloLimit):
)
-def is_internal_relay(request, public_key):
+def is_internal_relay(request: Request, public_key: str) -> bool:
"""
Checks if the relay is trusted (authorized for all project configs)
"""
@@ -99,7 +99,7 @@ def is_internal_relay(request, public_key):
return is_internal_ip(request)
-def is_static_relay(request):
+def is_static_relay(request: Request) -> bool:
"""
Checks if the request comes from a statically configured relay
@@ -141,7 +141,7 @@ def relay_from_id(request: Request, relay_id: str) -> tuple[Relay | None, bool]:
return None, False # no Relay found
why not pyannotate?
:'(
$ pyannotate --help
Traceback (most recent call last):
File ".venv/bin/pyannotate", line 5, in <module>
from pyannotate_tools.annotations.__main__ import main
File ".venv/lib/python3.13/site-packages/pyannotate_tools/annotations/__main__.py", line 9, in <module>
from lib2to3.main import StdoutRefactoringTool
ModuleNotFoundError: No module named 'lib2to3'
Metadata
Release files for auto-type-annotate 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| auto_type_annotate-1.1.2.tar.gz | 9.8 kB | Without provenance | Details for auto_type_annotate-1.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| auto_type_annotate-1.1.2-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for auto_type_annotate-1.1.2-py2.py3-none-any.whl |
Total release size: 20.2 kB
Release files / auto_type_annotate-1.1.2.tar.gz
| Download URL | auto_type_annotate-1.1.2.tar.gz |
|---|---|
| Size | 9.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9b01a829bbaf0ff212101755bf55146b7c1ac05835af8bb6923b54d730fbe76c
|
|
BLAKE2b-256 checksum How to use checksums |
78142733e010d284c011776cd48d2b764f17956bb27a1493b67cb1d0a0b9eedf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.2
|
Release files / auto_type_annotate-1.1.2-py2.py3-none-any.whl
| Download URL | auto_type_annotate-1.1.2-py2.py3-none-any.whl |
|---|---|
| Size | 10.4 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
c881a76d546464f9a25c8f926e94c6fba5caa40e646499ea5ec74e106eb7bf29
|
|
BLAKE2b-256 checksum How to use checksums |
810fbe7ae46439e95bdda0bec680e52e7f756839b691979e6e8cd6f84c9a5e76
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.2
|
Security for auto-type-annotate 1.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.