-
-
Notifications
You must be signed in to change notification settings - Fork 32k
bpo-34822: Simplify AST for subscription. #9605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
bd6d681
add0184
d15dfec
9f415fa
4a08f6d
42fef82
fe6989b
dbc3309
665476a
028e0fd
df65f31
e6e9ec7
aaa13c3
374bf22
f2226f3
338e13d
6cd32fa
a338ada
6e721c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -384,3 +384,11 @@ def __new__(cls, *args, **kwargs): | |
NameConstant: (type(None), bool), | ||
Ellipsis: (type(...),), | ||
} | ||
|
||
class Index(AST): | ||
def __new__(cls, value, *args, **kwargs): | ||
return value | ||
|
||
class ExtSlice(AST): | ||
def __new__(cls, dims=(), *args, **kwargs): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not make There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
but we cannot keep it working. We should have something to return from On other side,
will be broken because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P.S. There is a test ( |
||
return Tuple(list(dims), Load(), *args, **kwargs) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Simplified AST for subscription. Simple indices will be represented by their | ||
value, extended slices will be represented as tuples. :mod:`ast` classes | ||
``Index`` and ``ExtSlice`` are considered deprecated and will be removed in | ||
future Python versions. In meanwhile, ``Index(value)`` will return a ``value`` | ||
itself, ``ExtSlice(slices)`` will return ``Tuple(slices, Load())``. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe replace "will be" with "are now"? Also change "will return" into "now returns". (But "will be removed" must stay, since it is truly in the future.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there ever any additional positional
args
? (I presumekwargs
could belineno
etc.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No!