Skip to main content

Various AST utils

Project description

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

Project details


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.7.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

astate-0.0.7-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file astate-0.0.7.tar.gz.

File metadata

  • Download URL: astate-0.0.7.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for astate-0.0.7.tar.gz
Algorithm Hash digest
SHA256 f0f3092089184bd27f566e2390a48c88fbcd0793c2eef23666a9d3d9f06596e7
MD5 0dfed6a9f6a08d14bce4393927cdc879
BLAKE2b-256 54271fde86da3ffa36c32a48c3d048fb15c3dc66897397c0118fb6c923535d40

See more details on using hashes here.

File details

Details for the file astate-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: astate-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for astate-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 c497e98ad587238a07bb349f41e35be51301a3a419faf3ce2b39767b63d28959
MD5 f5fe098a26a8dd0b7d5702b761520896
BLAKE2b-256 c44fc922f3949d588e0df97866a25da8dcd159b08400c807e019e0225f752fec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page