This is a discussion thread for PEP 736 which is currently being prepared for its final draft.
Previous threads have generated a lot of conversation already so it would be really appreciated if you could read the PEP and previous discussions [1][2] before contributing and confirm whether your suggestion has already been addressed satisfactorily.
Based on the previous thread, the following decisions were made to the PEP:
Autoformatters
Maintainers of black wrote that if this PEP were to be adopted, black would be adapted to autoformat function calls of the form f(x=x)
to f(x=)
. There was significant disagreement as to whether this would be desirable. Prior to this, the draft of the PEP noted:
As with any other language feature, the programmer should exercise their own judgement about whether it is prudent to use it in any given context. We do not recommend enforcing a rule to use the feature in all cases where it may be applicable.
As described above, we propose that a reasonable rule of thumb would be to use this in cases where a parameter and its argument have the same semantics in order to reduce unintentional desynchronisation without causing inappropriate coupling.
We resolved to keep this text unchanged. As PEP authors, while we have our recommendations, we don’t think it’s our place to attempt to enforce philosophical rules about the language’s use. While this remains controversial, a lot of ink has been spilt on the issue and we’d encourage commenters not to add more without reviewing the previous thread to confirm that their point has not already been raised.
Highlighting exceptional arguments
Based in part on a blog post about the analogous feature added to Ruby, an additional advantage of this syntax was pointed out. Visual noise generated from keyword arguments being forwarded can give the impression that all the arguments are of this form. By applying this shorthand syntax, the exceptional arguments which are not of this form are more clearly emphasised.
How to Teach This section
The largest addition to the proposal was to expand the How to Teach This section. It now provides greater detail on how beginners and experienced practitioners can learn about the syntax and how to apply it. We additionally propose to name the syntax “keyword argument shorthand” to improve discoverability.
The AST
The implications that this syntax would have for the AST were clarified. The AST of the shorthand and traditional form would be identical, with the addition of a boolean flag attribute on AST nodes to indicate whether they are implicit in the code. This would enable, for example, linters to report on mixed styles.
IDEs
The conversation around IDEs was fleshed out and a section was added to the PEP with some recommendations to IDE maintainers.