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
Metadata
Release files for astate 0.0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| astate-0.0.8.tar.gz | 13.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| astate-0.0.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.8 kB
Release files / astate-0.0.8.tar.gz
| Download URL | astate-0.0.8.tar.gz |
|---|---|
| Size | 13.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fa660e58a4d0d44cf960524f37c01096c06a24045cb20ec421db04c4263521f1
|
|
BLAKE2b-256 checksum How to use checksums |
685010db3ebc83c653a3be8aac13d2e9f2976fc6f35211bb2b866c06435b6dd3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / astate-0.0.8-py3-none-any.whl
| Download URL | astate-0.0.8-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
58df66522b4d1c7ff1d0504087f08d075c8f6db229368311474c99393d672d39
|
|
BLAKE2b-256 checksum How to use checksums |
405fd3c435835bc342de03382f01710cd5e5e833fc0b9f7b3ff9b526133df3d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|