google-pasta is an AST-based Python refactoring library (version 0.2.0). It aims to enable robust Python source code refactoring through Abstract Syntax Tree (AST) modifications, useful for tasks like renaming modules, rewriting import statements, enforcing code style, or safely migrating code between APIs. The library is currently marked as 'Pre-Alpha' on PyPI and has a slow release cadence, with the last update in March 2020.
pip install google-pastaVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates the core functionality of `google-pasta`: parsing Python source code into an AST and then dumping it back into a string. A key design goal is 'symmetry', meaning `pasta.dump(pasta.parse(src))` should equal the original source code.
Ensure your environment's Python version matches the target code's Python version. Be cautious with newer Python syntax features (e.g., f-strings) if `pasta`'s development predates their full support.
Be aware of this limitation when designing refactoring tools. For transformations requiring indentation changes, post-processing with a linter/formatter might be necessary.
Test `pasta` thoroughly with codebases containing these unsupported features before relying on it for critical refactoring tasks.
Use with caution and thorough testing. Do not rely on it for mission-critical applications without extensive validation of its output.
Verify functionality with your specific Python version and syntax before use. Consider contributing to the project if you encounter issues or require newer feature support.
Avoid using `google-pasta` for code containing `async/await` syntax, or manually refactor such code. The library's development is slow, and full support for newer Python features may not be available in older versions.
Install the library using pip: `pip install google-pasta`.
Manually adjust indentation levels in your code if refactoring requires such changes, as `google-pasta` is not designed to handle this operation.
Refactor f-strings that exhibit this specific pattern to use alternative formatting methods or simpler f-string expressions that avoid the problematic syntax.
No dependency data recorded yet.