Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade version of typeguard in python runtime #4469

Closed
1 of 2 tasks
sam-goodwin opened this issue Mar 30, 2024 · 3 comments · Fixed by #4611
Closed
1 of 2 tasks

Upgrade version of typeguard in python runtime #4469

sam-goodwin opened this issue Mar 30, 2024 · 3 comments · Fixed by #4611
Assignees
Labels
feature-request A feature should be added or improved. p1

Comments

@sam-goodwin
Copy link

sam-goodwin commented Mar 30, 2024

Describe the feature

The python runtime for the CDK has an old and inflexible dependency on typeguard~=2.13.3

https://github.com/aws/jsii/blob/main/packages/%40jsii/python-runtime/setup.py#L37C10-L37C27

Use Case

I would like to have a CDK application include the latest pandera libraries but this fixed dependency is a blocker.

Proposed Solution

Increase the range and add version-aware adaptation code if required to handle the different versions.

Later versions of typeguard no longer accept the argname parameter. We'd have to change this line of code:

`check_type(argname=${JSON.stringify(
`argument ${name}`,
)}, value=${name}, expected_type=${expectedType})${comment}`,

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

Environment details (OS name and version, etc.)

Mac OS

@sam-goodwin sam-goodwin added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Mar 30, 2024
@sam-goodwin
Copy link
Author

sam-goodwin commented Mar 30, 2024

Just tested a monkey patch and removing the argname from the check_type function allows this to work for 3.0.2 up to 4.2.1

import typeguard

old_check_type = typeguard.check_type

def new_check_type(*args: Any, **kwargs: Any) -> Any:
    if "argname" in kwargs:
        del kwargs["argname"]
    return old_check_type(*args, **kwargs)

typeguard.check_type = new_check_type

But I do get a bunch of warnings:

/./packyak.config.py:11: UserWarning: Typeguard cannot check the IReusableStackSynthesizer protocol because it is a non-runtime protocol. If you would like to type check this protocol, please use @typing.runtime_checkable
  return old_check_type(*args, **kwargs)
/./packyak.config.py:11: UserWarning: Typeguard cannot check the IStackSynthesizer protocol because it is a non-runtime protocol. If you would like to type check this protocol, please use @typing.runtime_checkable
  return old_check_type(*args, **kwargs)

@mrgrain mrgrain added p1 feature-request A feature should be added or improved. and removed feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Apr 9, 2024
@iliapolo iliapolo self-assigned this Aug 20, 2024
@mergify mergify bot closed this as completed in #4611 Aug 27, 2024
@mergify mergify bot closed this as completed in 32ae5b0 Aug 27, 2024
Copy link
Contributor

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

1 similar comment
Copy link
Contributor

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. p1
Projects
None yet
3 participants