asttokens
asttokens copied to clipboard
Annotate Python AST trees with source text and token information
#87 had to be rushed through to fix #85. Followup tasks required: 1. Fix the coverage 2. Somehow test automatically that asttokens still works when astroid isn't installed.
I'm trying to package your module as an rpm package. So I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account. -...
I'm not sure if this is a problem in asttokens or astroid itself. If you believe it's the latter, please lemme know if I should file a bug there. When...
https://docs.python.org/3/whatsnew/3.10.html - Pattern matching. One quick way is to add this so that `test_sys_modules` tests it: ```python try: import test.test_patma except ImportError: pass ``` This works, which suggests that no...
The main pain point I have with asttokens is when there's a non-AST object inside of the AST that semantically has a token span, but which asttokens does not expose...
The following sample: ```python import asttokens sample = """from foo import bar""" astt = asttokens.ASTTokens(sample, parse=True) print(astt.tree.body[0].names[0].first_token) ``` displays `from` but it should really display `bar`
With `tokenize` module: ``` >>> next(tokenize.generate_tokens(iter(['()\n']).__next__)).type == token.OP True >>> next(tokenize.generate_tokens(iter(['()\n']).__next__)).exact_type == token.LPAR True ``` With `asttokens`: ``` >>> asttokens.ASTTokens('()\n', True).tokens[0].type == token.OP True >>> asttokens.ASTTokens('()\n', True).tokens[0].exact_type == token.LPAR Traceback...
In Python < 3.8, `get_text` doesn't include the surrounding parentheses in generator expressions. For example: ```python import ast import asttokens source = "list(x for x in y)" atok = asttokens.ASTTokens(source,...
I am trying to use `asttokens` for source-level transformations in a code editor. For example, I would like to position the cursor on a binary operation, press a key, and...
Because of https://bugs.python.org/issue29051, a temporary solution (See https://github.com/gristlabs/asttokens/issues/4) was placed to avoid exceptions. This issue is to track this workaround's life time so it could be fixed once the above...