Skip to content

Disable Python Argument Lifting #4721

Open
@rehanvdm

Description

@rehanvdm

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

  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.

    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.

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) 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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumMedium work item – a couple days of effortfeature-requestA feature should be added or improved.p2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions