This repository was archived by the owner on Oct 1, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 41
Non-injective token to AST mappings #22
Comments
|
The comma syntax in The nested Part of the issue is that there's not a good way to break with (
Foo() as foo,
Bar() as bar,
):
pass
with (
Foo() as foo
), (
Bar() as bar
):
pass The closest is something like: with \
Foo() as foo, \
Bar() as bar:
pass But this is less than pretty. |
Makes you wish they didn't drop |
YAPF's output here is good for a giggle, though: # In:
with \
Foo() as foo, \
Foo() as foo_2, \
Bar(
long_argument,
long_argument,
long_argument,
long_argument,
long_argument,
) as bar, \
Baz(some_arg) as baz, \
Baz(some_arg) as baz_2 \
:
pass
# Out:
with Foo() as foo, Foo() as foo_2, Bar(
long_argument,
long_argument,
long_argument,
long_argument,
long_argument,
) as bar, Baz(some_arg) as baz, Baz(some_arg) as baz_2:
pass |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
There are a number of cases in Python where the token-to-AST mapping is very clearly non-injective, where multiple different-looking statements are syntactically equivalent. We should think about how to handle these; perhaps this will require looking at the actual tokens.
Usually only one use case is common, but mangling tokens might be a bit much.
1.
elif
(#7)2. Nested
with
in Python 2 (#15)3.
as
inexcept
in Python 24. Empty parent class
The text was updated successfully, but these errors were encountered: