What is com2ann?
mastercom2ann is a tool designed to translate Python type comments into modern Python type annotations. It is built with a philosophy of being minimally invasive, working at the source code and tokenizer level rather than using AST un-parsing. This ensures that original code formatting is preserved as much as possible, including the placement of non-type comments.
Key capabilities:
- Translates function signature type comments to annotations.
- Translates assignment type comments to annotations.
- Supports target Python versions from 3.4+.
- Can be configured to wrap long function signatures.
- Can be configured to drop redundant assignment values (like
Noneor...) when generating stubs.