LibCST icon indicating copy to clipboard operation
LibCST copied to clipboard

A concrete syntax tree parser and serializer library for Python that preserves many aspects of Python's abstract syntax tree

Results 171 LibCST issues
Sort by recently updated
recently updated
newest added

In a local scope, e.g. inside a function, class, if condition. The comment is associated with the statement correctly. ``` In [10]: code = """ ...: def f(): ...: #...

parsing

Raise more specific errors when a statement is passed in to `parse_expression`, or multiple statements to `parse_statement`. ``` ParserError: Failed to parse expression - found statement tokens Caused by ParserSyntaxError:...

enhancement
parsing

This is definietly not a realistic code (but it is still used in projects [like this](https://github.com/facebook/facebook-python-business-sdk/blob/95e64a10d987d7a53963d17036b6730d07f84ab5/facebook_business/test/integration_campaign.py#L44-L77)), though I think it might point to an underlying stack overflow or something like...

bug
parsing

In fact this is captured as a test case in https://github.com/instagram/libcst/blob/f36eacb1327830fad51e08084b46601cad681ae0/libcst/_nodes/tests/test_import.py#L394-L401 ``` cst.ImportFrom( module=cst.Name("foo"), names=( cst.ImportAlias(cst.Name("bar"), comma=cst.Comma()), cst.ImportAlias(cst.Name("baz"), comma=cst.Comma()), ), ) ``` This node generates `from foo import bar,baz,` which...

bug
parsing

```python from libcst import * attr = Attribute( value=List(elements=[]), attr=Name(value="append"), dot=Dot(whitespace_before=ParenthesizedWhitespace( first_line=TrailingWhitespace(newline=Newline())) ), ) node = Call(func=attr, args=[Arg(value=Integer(value="1"))]) code = Module([]).code_for_node(node) assert code == "[]\n.append(1)" parse_module(code) # error, invalid syntax!...

bug
parsing

```python import libcst as cst code = """ from math import (nan as NaN) """ compile(code, "", "exec") # (no error) cst.parse_module(code) # ParserSyntaxError: Syntax Error @ 4:9. # Internal...

bug
parsing

eg I expect the following to generate `'{"ham": "spam", **({"x": x} if x else {})}'` ```python from libcst import ( Dict, DictElement, SimpleString, Name, LeftParen, RightParen, StarredDictElement, IfExp, Module, parse_expression,...

bug
parsing

For example it can be a `Subscript`, not just `Name | List | Tuple`. In fact I think there are two kinds of `AsName`s - the ones in imports and...

documentation
good first issue
parsing

According to [the docs](https://libcst.readthedocs.io/en/latest/nodes.html#libcst.Assign.value) `Assign.value` is supposed to be a `BaseExpression`, but: ``` echo "f = *2" | python -m libcst.tool print - Module( body=[ SimpleStatementLine( body=[ Assign( targets=[ AssignTarget(...

documentation
good first issue
parsing

The [fine docs](https://libcst.readthedocs.io/en/latest/nodes.html#libcst.GeneratorExp.elt) say that `elt` in the various comprehension nodes are of type `BaseAssignTargetExpression`. This is a lie. Observe: in the syntactically correct and semantically plausible expression `(i **...

documentation
good first issue
parsing