jsii icon indicating copy to clipboard operation
jsii copied to clipboard

(aws_cdk): Allow Python Path objects into functions that need paths

Open InvincibleRMC opened this issue 1 year ago • 4 comments

Describe the feature

Allow using Path object in python for when a path to something is needed.

Use Case

For example to use a Code.from_asset() function I need to turn my Path object into str. It would be nice to not have to do this cast.

Code.from_asset(str(Path().cwd() / 'aws_infrastructure' / 'lambda_functions')),

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

2.154.1 (build febce9d)

Environment details (OS name and version, etc.)

Ubuntu 24.04

InvincibleRMC avatar Nov 20 '24 18:11 InvincibleRMC

@InvincibleRMC Good afternoon. If I understand your use case properly, you want to support for overloaded version of Code.from_asset() where it accepts Python's Path() object, instead of requiring to convert into str (string). I'm not sure if it could be supported. The reasoning is that Python CDK library is generated from JSII bindings (it is a specialized process) and supporting language specific class might not be feasible since there might not be overlap across different supported CDK languages. I could review this with team.

Thanks, Ashish

ashishdhingra avatar Nov 22 '24 20:11 ashishdhingra

That correctly summarizes my use case. If it is not possible I understand, it would just be more convenient.

InvincibleRMC avatar Nov 22 '24 21:11 InvincibleRMC

This could be JSII-related. Reaching out to core team for further inputs here.

ashishdhingra avatar Nov 25 '24 17:11 ashishdhingra

It's exactly as you said @ashishdhingra.

We have to be multi-language compatible, and not all languages have a Path type. I understand why this would be nice, but it's unlikely to happen soon.

We could do the language-specific conversion in the Python runtime over in the jsii repository: https://github.com/aws/jsii. This issue makes for a good feature request over there.

But again, unlikely to be done by us soon. I would accept someone submitting it if they can demonstrate a high degree of confidence that they understand how jsii works and why this change will not cause any unexpected problems.

rix0rrr avatar Nov 27 '24 15:11 rix0rrr