A Python tool that re-applies type annotations from .pyi stub files back into your source code.
retype is a Python tool that re-applies type annotations from .pyi stub files back into your Python source code. It automates the process of synchronizing type hints between stub files and implementation, converting type comments to modern annotation syntax. This helps developers maintain consistent type information across their codebase, especially when using gradual typing or migrating from Python 2.
Python developers working with type annotations, particularly those using mypy or other static type checkers with .pyi stub files. It's useful for teams maintaining large codebases with separate type stubs or migrating from type comments to annotation syntax.
Developers choose retype because it automates the tedious manual process of keeping type stubs and source code synchronized. It provides validation to prevent inconsistencies and supports incremental adoption, making it safer than manual editing for large codebases.
Re-apply type annotations from .pyi stubs to your codebase.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Reapplies typing imports, function signatures, and variable annotations from .pyi files to .py sources, automating a manual and error-prone process as described in the usage section.
Validates existing source annotations against stubs and checks for signature compatibility, raising errors for mismatches to ensure type consistency.
With the --incremental flag, it allows missing annotations in both stubs and source, supporting gradual adoption without strict completeness.
Reads and converts type comments in .pyi files to annotations and removes duplicates from source, easing migration from older Python 2/3 comment syntax.
The project has been unmaintained since August 2022, meaning no bug fixes, security updates, or compatibility with newer Python versions or tools.
Annotated sources lose original line numbers due to imported typing definitions, complicating debugging and tool integration as noted in known limitations.
Does not automatically stringify forward references in stubs, requiring manual edits to avoid runtime errors, which can be tedious for complex codebases.