Skip to content
Branch: master
Find file History
rchen152 Support import-as and combining from-imports in merge_pyi.
* Instead of using touch_import(), print and reparse import statements so that
  we can put multiple imports from the same package on one line.
* This makes it easy to support import-as, so I've done that as well.

Fixes #330.

#pyfixit

PiperOrigin-RevId: 252169902
Latest commit 187795b Jun 7, 2019
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
test_data Support import-as and combining from-imports in merge_pyi. Jun 8, 2019
CMakeLists.txt Fix a merge-pyi crash in Python versions before 3.6. Jun 6, 2019
Grammar.txt Fix a merge-pyi crash in Python versions before 3.6. Jun 6, 2019
README.md Update merge-pyi's README to reflect the argparse --help change. Jan 7, 2019
__init__.py Add a script which runs pytype tests. Jun 2, 2018
main.py Give long names to all the merge-pyi options. Jun 8, 2019
merge_pyi.py
merge_pyi_test.py

README.md

Copy type annotations from a PEP484 stub file into python source.

This script is Python 2 and 3 compatible.

Sample uses:

Print to stdout what simple.py would look like with the type annotations from simple.pyi added:

   merge-pyi test_data/simple.py test_data/simple.pyi

Print to stdout what simple.py would look like with the type annotations from simple.pyi added as type comments:

   merge-pyi --as-comments test_data/simple.py test_data/simple.pyi

Output a diff of the changes to simple.py:

   merge-pyi --diff test_data/simple.py test_data/simple.pyi

Overwrite simple.py:

   merge-pyi -i test_data/simple.py test_data/simple.pyi

Regression tests

test_data/foo.py  : input we want to annotate
test_data/foo.pyi : type hints we want to add to foo.py (may be intentionally bad)

test_data/foo.comment.py : expected output, inserting types as comments
test_data/foo.pep484.py  : expected output, inserting types in PEP484 style
You can’t perform that action at this time.