Skip to content

Upgrade version of typeguard in python runtime #4469

Closed

Description

@sam-goodwin

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

Activity

  1. added
    feature-request
    needs-triage
    on Mar 30, 2024
  2. sam-goodwin commented on Mar 30, 2024

    @sam-goodwin
    Author

    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)
  3. added
    feature-request
    and removed
    feature-request
    needs-triage
    on Apr 9, 2024
  4. self-assigned this
    on Aug 20, 2024
  5. github-actions commented on Aug 27, 2024

    @github-actions
    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.

  6. github-actions commented on Aug 27, 2024

    @github-actions
    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

Metadata

Metadata

Assignees

Labels

feature-requestp1

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions