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
>>> 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.
>>> 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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
astate-0.0.8.tar.gz
(13.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file astate-0.0.8.tar.gz.
File metadata
- Download URL: astate-0.0.8.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa660e58a4d0d44cf960524f37c01096c06a24045cb20ec421db04c4263521f1
|
|
| MD5 |
78359bf47a757c8415bbec43054d3907
|
|
| BLAKE2b-256 |
685010db3ebc83c653a3be8aac13d2e9f2976fc6f35211bb2b866c06435b6dd3
|
File details
Details for the file astate-0.0.8-py3-none-any.whl.
File metadata
- Download URL: astate-0.0.8-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58df66522b4d1c7ff1d0504087f08d075c8f6db229368311474c99393d672d39
|
|
| MD5 |
13adc6b1fda5d0b598b368c7fc0c975a
|
|
| BLAKE2b-256 |
405fd3c435835bc342de03382f01710cd5e5e833fc0b9f7b3ff9b526133df3d6
|