A Python tool that converts type comments into modern type annotations while preserving original formatting.
com2ann is a Python tool that automatically converts legacy type comments into modern type annotation syntax. It solves the problem of migrating Python codebases from older typing conventions to newer Python 3.4+ type annotations while preserving code formatting.
Python developers maintaining legacy codebases with type comments, teams migrating to modern Python typing standards, and library maintainers updating their type hints.
Developers choose com2ann because it provides a reliable, formatting-preserving migration path for type comments, avoiding the disruptive formatting changes that often come with AST-based refactoring tools.
Tool for translation type comments to type annotations in Python
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses tokenizer-level processing to maintain original code formatting, avoiding disruptive changes from AST unparsing, as emphasized in the philosophy.
Includes options like --drop-ellipsis and --drop-none for cleaning up stub files by removing redundant values, making it ideal for type stub preparation.
Supports translation for Python 3.4+ codebases with configurable minor version targeting via --python-minor-version, ensuring backward compatibility.
Focuses solely on converting type comments without imposing opinionated style changes, preserving developer intent and reducing migration friction.
Only handles type comment conversion, lacking features for broader type hint improvements, error checking, or integration with type checkers like mypy.
Requires Python 3.8 to execute, which may hinder adoption in environments with older Python versions or legacy systems.
While it preserves formatting, it doesn't integrate with popular formatters, potentially leaving code inconsistently styled after conversion unless manually processed.