I have done something similar using https://pybowler.io/. This library wraps the LibCST library and abstracts away some of the refactoring operations into nice wrapper functions.
Are you sure it wraps the LibCST library (https://github.com/Instagram/LibCST)?
> Bowler builds on top of the Concrete Syntax Tree (CST) provided by lib2to3 in the standard library.