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
Refactor rules for class_def and arguments #135
Refactor rules for class_def and arguments #135
Conversation
99ea20a
to
8c45477
Compare
''' | ||
class C(A, x=2, *[B, C], y=3): | ||
pass | ||
'''), |
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.
I think we are missing a case with *args and **kwargs at the same time, which is valid in current Python:
>>> class A(x,y,*something,**more_something): pass
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.
Oh yes, thats right! Another problem is that this currently allows generator expressions in the arguments, which is not valid Python, if I'm not mistaken.
Edit: Never mind my comment about genexprs, I had already fixed that, but forgot about it. Also, I added one more test case.
@pablogsal @gvanrossum Is it okay if I push a PR that builds up on this for issues #126 and #136? |
Yeah, as long as you’re not afraid of some merge conflicts.
--
--Guido (mobile)
|
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.
This is a very subtle area! I've deleted more comments than I've left...
data/simpy.gram
Outdated
seq_extract_starred_exprs(p, a), | ||
seq_delete_starred_exprs(p, a), | ||
EXTRA) } | ||
| a=posarg b=[',' c=args { c }] { |
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.
Looks like we can get rid of posarg
and instead write a=named_expression
here -- the case where posarg
matches starred_expression
is already handled by the first alternative.
(Things are still weird -- one confusing thing is that starred_expression
must start with *
, while named_expression
may or may not contain a :=
operator. But I don't think we can simplify further, since the resolution of "ambiguities" is quite subtle for this rule.)
Closes #122.