Open osqui0110 opened 10 months ago
Dear AWS Team,
We are in the same situation as @osqui0110. Would it be possible to update the typeguard version.
Thank you and all the best!
I hoppend a PR for jsii to fix this: https://github.com/aws/jsii/pull/4455 It would be great if someone could review it.
@mrgrain Me again, seeing a similar issue here with pinned typeguard package for the python runtime. Let me know if you think this can also be upgraded. Thanks.
The latest release should include this: https://github.com/aws/constructs/releases/tag/v10.3.1
LMK if it works.
The latest release should include this: https://github.com/aws/constructs/releases/tag/v10.3.1
LMK if it works.
You're the best! Looks like we are all good now. Thanks.
constructs==10.3.1
(which pip installed with typeguard==4.3.0
) broke our deployment which was creating an NLB through aws-cdk-lib==2.162.0
, just as an FYI:
$ python
Python 3.12.7 (main, Oct 7 2024, 11:35:44) [Clang 16.0.0 (clang-1600.0.26.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from aws_cdk import aws_ec2 as ec2, aws_elasticloadbalancingv2 as elb2
>>> from aws_cdk import Stack
>>> stack = Stack()
>>> vpc = ec2.Vpc(stack, "test-vpc")
>>> nlb = elb2.NetworkLoadBalancer(stack, "test-nlb", vpc=vpc)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/.../.pyenv/versions/.../lib/python3.12/site-packages/jsii/_runtime.py", line 118, in __call__
inst = super(JSIIMeta, cast(JSIIMeta, cls)).__call__(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/.../.pyenv/versions/.../lib/python3.12/site-packages/aws_cdk/aws_elasticloadbalancingv2/__init__.py", line 16504, in __init__
props = NetworkLoadBalancerProps(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/.../.pyenv/versions/.../lib/python3.12/site-packages/aws_cdk/aws_elasticloadbalancingv2/__init__.py", line 17314, in __init__
check_type(argname="argument vpc", value=vpc, expected_type=type_hints["vpc"])
File "/Users/.../.pyenv/versions/.../lib/python3.12/site-packages/aws_cdk/aws_elasticloadbalancingv2/__init__.py", line 967, in check_type
typeguard.check_type(value=value, expected_type=expected_type, collection_check_strategy=typeguard.CollectionCheckStrategy.ALL_ITEMS) # type:ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/.../.pyenv/versions/.../lib/python3.12/site-packages/typeguard/_functions.py", line 106, in check_type
check_type_internal(value, expected_type, memo)
File "/Users/.../.pyenv/versions/.../lib/python3.12/site-packages/typeguard/_checkers.py", line 861, in check_type_internal
checker(value, origin_type, args, memo)
File "/Users/.../.pyenv/versions/.../lib/python3.12/site-packages/typeguard/_checkers.py", line 729, in check_protocol
raise TypeCheckError(
typeguard.TypeCheckError: aws_cdk.aws_ec2.Vpc is not compatible with the IVpc protocol because its 'add_client_vpn_endpoint' method has mandatory keyword-only arguments in its declaration: cidr, server_certificate_arn
Thanks for the report @berkaycagir Can you help me understand what's the issue here?
It looks the new release of constructs caused your python project to now install typeguard v4, whereas previously it would pick typeguard v2?
And with that newer version of typeguard, there's an incompatibility with the VPC construct in aws-cdk-lib?
Does that some it up alright?
constructs==10.3.1
(which pip installed withtypeguard==4.3.0
) broke our deployment which was creating an NLB throughaws-cdk-lib==2.162.0
, just as an FYI:$ python Python 3.12.7 (main, Oct 7 2024, 11:35:44) [Clang 16.0.0 (clang-1600.0.26.3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from aws_cdk import aws_ec2 as ec2, aws_elasticloadbalancingv2 as elb2 >>> from aws_cdk import Stack >>> stack = Stack() >>> vpc = ec2.Vpc(stack, "test-vpc") >>> nlb = elb2.NetworkLoadBalancer(stack, "test-nlb", vpc=vpc) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/.../.pyenv/versions/.../lib/python3.12/site-packages/jsii/_runtime.py", line 118, in __call__ inst = super(JSIIMeta, cast(JSIIMeta, cls)).__call__(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/.../.pyenv/versions/.../lib/python3.12/site-packages/aws_cdk/aws_elasticloadbalancingv2/__init__.py", line 16504, in __init__ props = NetworkLoadBalancerProps( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/.../.pyenv/versions/.../lib/python3.12/site-packages/aws_cdk/aws_elasticloadbalancingv2/__init__.py", line 17314, in __init__ check_type(argname="argument vpc", value=vpc, expected_type=type_hints["vpc"]) File "/Users/.../.pyenv/versions/.../lib/python3.12/site-packages/aws_cdk/aws_elasticloadbalancingv2/__init__.py", line 967, in check_type typeguard.check_type(value=value, expected_type=expected_type, collection_check_strategy=typeguard.CollectionCheckStrategy.ALL_ITEMS) # type:ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/.../.pyenv/versions/.../lib/python3.12/site-packages/typeguard/_functions.py", line 106, in check_type check_type_internal(value, expected_type, memo) File "/Users/.../.pyenv/versions/.../lib/python3.12/site-packages/typeguard/_checkers.py", line 861, in check_type_internal checker(value, origin_type, args, memo) File "/Users/.../.pyenv/versions/.../lib/python3.12/site-packages/typeguard/_checkers.py", line 729, in check_protocol raise TypeCheckError( typeguard.TypeCheckError: aws_cdk.aws_ec2.Vpc is not compatible with the IVpc protocol because its 'add_client_vpn_endpoint' method has mandatory keyword-only arguments in its declaration: cidr, server_certificate_arn
The new typeguard is doing what it should. This error is due to a bug that let's jsii generate broken python code: https://github.com/aws/jsii/issues/4541
Yes, there's clearly something wrong with the code jsii produces.
https://github.com/aws/jsii/issues/4541 is a known issue, but this case seems to be different because the keyword args do match in both protocol and implementation. 🤔
Continuing the conversation here: https://github.com/aws/jsii/issues/4658
We yanked the 10.3.1 release of constructs from PyPI as a quick mitigation for most users. https://pypi.org/project/constructs/10.3.1/
We will revert this to an older version of typeguard soon.
Re-opened this issue to track that we eventually need to release support for newer typeguard versions.
To discuss the issue itself, please use https://github.com/aws/jsii/issues/4658
Thanks for the report @berkaycagir Can you help me understand what's the issue here?
It looks the new release of constructs caused your python project to now install typeguard v4, whereas previously it would pick typeguard v2?
And with that newer version of typeguard, there's an incompatibility with the VPC construct in aws-cdk-lib?
Does that some it up alright?
I'm sorry I wasn't able to provide more details; but thank you very much for following up on it and the yank, I appreciate it.
Hey! I'm not sure about how you manage python dependencies. I'm working on a project using glue Python shell scripts. Trying to add Pandera to validate Pandas DFs, my dependency manager (poetry) shows:
That version of Typeguard is quite old (currently 4.x)
Is it possible to use updated dependencies? thx!