Mypy: Convert Python 2 type hints to Python 3

Created on 3 Jan 2020  路  2Comments  路  Source: python/mypy

Is there a feature available in mypy or elsewhere to convert Python 2 Type Hint comments to Python 3 syntax? With Python 2 going EOL, there should be something available to help users convert their code to the cleaner syntax.

Thanks.

question

Most helpful comment

The best tool I know of is com2ann (https://github.com/ilevkivskyi/com2ann) which was written by Ivan.

All 2 comments

A possible approach would be using misc/fix_annotate.py with lib2to3 to generate Python3 code. However, I haven't practiced it yet

The best tool I know of is com2ann (https://github.com/ilevkivskyi/com2ann) which was written by Ivan.

Was this page helpful?
0 / 5 - 0 ratings