Disable Python Argument Lifting
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 267
- Avg merge
- 1d 25m
- Merged PRs (30d)
- 14
Description
### Describe the feature
An option to disable Python argument lifting for the whole project or specific functions and constructors.
### Use Case
I need help turning "argument lifting in Python" off. By chance, I found some mention of this in the docs as I did not even know how to ask this question. https://aws.github.io/jsii/user-guides/language-support
It will automatically "deconstruct" the properties of the last argument if that argument is an interface.
The docs say it applies to constructors but it applies to any function it seems.
Let's take this example. I have two functions
```ts
public static async diffAll(props: DataLandingZoneProps) {
return diff.all(props);
}
public static async diffSelect(props: DataLandingZoneProps, id: string) {
return diff.select(props, id);
}
```
For diffAll the last (and only) argument is an interface. So JSII decides to deconstruct/argument lift (help me with the correct word here?, not a Python dev) and when calling it wants you to pass in each of the properties.
```python
def diff_all(
cls,
*,
budgets: typing.Sequence[typing.Union[DlzBudgetProps, typing.Dict[builtins.str, typing.Any]]],
local_profile: builtins.str,
mandatory_tags: typing.Union[MandatoryTags, typing.Dict[builtins.str, typing.Any]],
organization: typing.Union[DLzOrganization, typing.Dict[builtins.str, typing.Any]],
regions: typing.Union[DlzRegions, typing.Dict[builtins.str, typing.Any]],
security_hub_notifications: typing.Sequence[typing.Union["SecurityHubNotification", typing.Dict[builtins.str, typing.Any]]],
additional_mandatory_tags: typing.Optional[typing.Sequence[typing.Union[DlzTag, typing.Dict[builtins.str, typing.Any]]]] = None,
default_notification: typing.Optional[typing.Union[NotificationDetailsProps, typing.Dict[builtins.str, typing.Any]]] = None,
deny_service_list: typing.Optional[typing.Sequence[builtins.str]] = None,
deployment_platform: typing.Optional[typing.Union[DeploymentPlatform, typing.Dict[builtins.str, typing.Any]]] = None,
iam_identity_center: typing.Optional[typing.Union[IamIdentityCenterProps, typing.Dict[builtins.str, typing.Any]]] = None,
iam_policy_permission_boundary: typing.Optional[typing.Union[IamPolicyPermissionsBoundaryProps, typing.Dict[builtins.str, typing.Any]]] = None,
network: typing.Optional[typing.Union[Network, typing.Dict[builtins.str, typing.Any]]] = None,
print_deployment_order: typing.Optional[builtins.bool] = None,
print_report: typing.Optional[builtins.bool] = None,
save_report: typing.Optional[builtins.bool] = None,
) -> None:
```
For diffSelect the last argument is not an interface, so it leaves the first argument that is an interface alone and does not expand it.
```python
def diff_select(
cls,
props: typing.Union[DataLandingZoneProps, typing.Dict[builtins.str, typing.Any]],
id: builtins.str,
) -> None:
```
How can I stop this argument lifting? I peeked at the source (the `getliftedProp` function is defined [here](https://github.com/aws/jsii/blob/4f930f6024aa6df4823d2a4c9ae34d9af983792f/packages/jsii-pacmak/lib/targets/python.ts#L3014)) and it does not seem an option like this exists?
### Proposed Solution
_No response_
### Other Information
_No response_
### Acknowledgements
- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
### CDK version used
-
### Environment details (OS name and version, etc.)
-
Contributor guide
Research direction
Start with the language-support documentation and packages/jsii-pacmak/lib/targets/python.ts, especially getliftedProp. Trace how constructors and functions are generated, then determine how project-, function-, and constructor-level opt-outs would be represented. Done means generated Python APIs can preserve the interface argument where the requested option is enabled, with coverage for the described diffAll and diffSelect cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, typescript
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100