feat(python): encode positional-only arguments in signatures#4197
Draft
RomainMuller wants to merge 3 commits intomainfrom
Draft
feat(python): encode positional-only arguments in signatures#4197RomainMuller wants to merge 3 commits intomainfrom
RomainMuller wants to merge 3 commits intomainfrom
Conversation
Now that Python 3.7 reached end-of-life, and since Python 3.8 and greater have support for positional-only argument notation (any argument before a `/` delimiter may only be passed positionally), adjust code generation to leverage this feature in order to address issues where inheritance hierarchies would rename parameters, which is a non-issue in all languages but Python, where those could always be provided as keyword arguments before. Fixes #2927 BREAKING CHANGE: the generated Python code now requires Python 3.8 or later and encodes positional arguments as positional-only, making keyword-style usage impossible. Users who used the keyword-style convention need to update their code to use the positional syntax instead.
97a2adb to
17371dd
Compare
# Conflicts: # packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.js.snap
Is it necessary to rename them? I think it would be much better to keep keyword-style parameters and just use the parameter names consistently. For me it is a great benefit of Python and in many cases it would be even better to have keyword-style-only parameters other than positional-only. |
Contributor
|
This might not be the desired solution. See #2927 (comment) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Now that Python 3.7 reached end-of-life, and since Python 3.8 and greater have support for positional-only argument notation (any argument before a
/delimiter may only be passed positionally), adjust code generation to leverage this feature in order to address issues where inheritance hierarchies would rename parameters, which is a non-issue in all languages but Python, where those could always be provided as keyword arguments before.Fixes #4541
BREAKING CHANGE: the generated Python code now requires Python 3.8 or later and encodes positional arguments as positional-only, making keyword-style usage impossible. Users who used the keyword-style convention need to update their code to use the positional syntax instead.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.