Skip to content

consider renaming the "id" parameter for constructs (reserved word in Python) #3203

@bverhoeve

Description

@bverhoeve

Note: for support questions, please first reference our documentation, then use Stackoverflow. This repository's issues are intended for feature requests and bug reports.

  • I'm submitting a ...

    • 🪲 bug report
    • 🚀 feature request
    • 📚 construct library gap
    • ☎️ security issue or vulnerability => Please see policy
    • ❓ support request => Please see note at the top of this template.
  • What is the current behavior?
    To create a new Construct (or any other Resource) using CDK, the constructor in Python has the following syntax:

 class aws_cdk.core.Construct(scope, id)

The id parameter serves as a unique id for CloudFormation. Naming a parameter id in Python is not really good practice, since id() is a built-in function in the Python standard library, which represents the address of the object in memory in CPython. (see https://docs.python.org/3/library/functions.html#id)

I think this could lead to potentials errors down the line for users that use the Python variant of CDK, since the id parameter could clash with the id() function.

  • What is the expected behavior (or behavior of feature suggested)?
    If possible, renaming the id parameter to something like identifier or cdk_id would avoid having this parameter clash with the built-in id() function.

  • What is the motivation / use case for changing the behavior or adding this feature?
    Clashes with Python standard library built-in functions.

  • Please tell us about your environment:

    • CDK CLI Version: 0.36.2
    • Module Version: 0.36.2.0
    • OS: [all]
    • Language: [Python ]
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. associated pull-request, stackoverflow, gitter, etc)

Metadata

Metadata

Assignees

Labels

@aws-cdk/coreRelated to core CDK functionalityeffort/mediumMedium work item – several days of effortfeature-requestA feature should be added or improved.language/pythonRelated to Python bindings

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions