jsii icon indicating copy to clipboard operation
jsii copied to clipboard

feat(python): encode positional-only arguments in signatures

Open RomainMuller opened this issue 2 years ago • 2 comments

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 https://github.com/aws/jsii/issues/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.

RomainMuller avatar Jul 26 '23 11:07 RomainMuller

where inheritance hierarchies would rename parameters

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.

rafrafek avatar Aug 10 '23 11:08 rafrafek