Metadata-Version: 2.4
Name: astate
Version: 0.0.8
Summary: Various AST utils
Project-URL: Homepage, https://github.com/thorwhalen/astate
Author: Thor Whalen
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: ast,code-analysis,metaprogramming,python,static-analysis
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Code Generators
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Provides-Extra: dev
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Provides-Extra: docs
Requires-Dist: sphinx-rtd-theme>=1.0; extra == 'docs'
Requires-Dist: sphinx>=6.0; extra == 'docs'
Description-Content-Type: text/markdown

# astate

Various AST utils

To install:	```pip install astate```

# Examples


## re_find_in_body

Recursively find elements in an ast body that satisfy a condition

```python
>>> from astate import re_find_in_body
>>> def foo(x):
...     def bar(y):
...         y * 1
...     return bar(x)
>>>
>>> [x.name for x in re_find_in_body(foo)]
['foo', 'bar']
>>> [x.name for x in re_find_in_body(foo, max_levels=1)]
['foo']
```
    
## remove_docstrings

Remove docstrings from the given Python code.

```python
>>> from astate import remove_docstrings
>>> code = '''
... def foo():
...     """This is a docstring."""
...     print("Hello")
...
... class Bar:
...     """Class docstring."""
...     def baz(self):
...         """Method docstring."""
...         pass
... '''
>>> print(remove_docstrings(code))
def foo():
    print('Hello')
<BLANKLINE>
class Bar:
<BLANKLINE>
    def baz(self):
        pass
```