Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not add imports if we added no type info in ATAV
In ApplyTypeAnnotationsVisitor, there are edge cases where we might have changed the module imports even though we never wound up applying any type annotations. This will become even more common if we support adding `from __future__ import annotations`, which I would like to do soon. To handle this, we can simply return the original tree from `transform_module_impl` (discarding any changes from either `self` or `AddImportsVisitor`) whenever there are no changes in `self.annotation_counts`. I updated the no-annotations-changed test to reflect this: ``` > python -m unittest libcst.codemod.visitors.tests.test_apply_type_annotations.TestApplyAnnotationsVisitor ............................................... ---------------------------------------------------------------------- Ran 47 tests in 2.312s OK ```
- Loading branch information