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

Update Python dependencies (typeguard) #2063

Open
osqui0110 opened this issue Jan 18, 2024 · 12 comments
Open

Update Python dependencies (typeguard) #2063

osqui0110 opened this issue Jan 18, 2024 · 12 comments

Comments

@osqui0110
Copy link

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:

Because no versions of pandera match >0.18.0,<0.19.0
 and pandera (0.18.0) depends on typeguard (>=3.0.2), pandera (>=0.18.0,<0.19.0) requires typeguard (>=3.0.2).
And because constructs (10.3.0) depends on typeguard (>=2.13.3,<2.14.0)
 and no versions of constructs match >10.3.0,<11.0.0, pandera (>=0.18.0,<0.19.0) is incompatible with constructs (>=10.3.0,<11.0.0).
So, because testglue depends on both constructs (^10.3.0) and pandera (^0.18.0), version solving failed.

That version of Typeguard is quite old (currently 4.x)

Is it possible to use updated dependencies?
thx!

@iwanbolzern
Copy link

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!

@iwanbolzern
Copy link

I hoppend a PR for jsii to fix this: aws/jsii#4455 It would be great if someone could review it.

@MatthewGrant
Copy link

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

@mrgrain
Copy link
Contributor

mrgrain commented Oct 10, 2024

The latest release should include this: https://github.com/aws/constructs/releases/tag/v10.3.1

LMK if it works.

@mrgrain mrgrain closed this as completed Oct 10, 2024
@MatthewGrant
Copy link

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.

@berkaycagir
Copy link

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

@mrgrain
Copy link
Contributor

mrgrain commented Oct 11, 2024

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?

@fraghag
Copy link

fraghag commented Oct 11, 2024

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

The new typeguard is doing what it should.
This error is due to a bug that let's jsii generate broken python code:
aws/jsii#4541

@mrgrain
Copy link
Contributor

mrgrain commented Oct 11, 2024

Yes, there's clearly something wrong with the code jsii produces.

aws/jsii#4541 is a known issue, but this case seems to be different because the keyword args do match in both protocol and implementation. 🤔

@mrgrain
Copy link
Contributor

mrgrain commented Oct 11, 2024

Continuing the conversation here: aws/jsii#4658

@aws aws locked as resolved and limited conversation to collaborators Oct 11, 2024
@mrgrain mrgrain reopened this Oct 11, 2024
@aws aws unlocked this conversation Oct 11, 2024
@mrgrain
Copy link
Contributor

mrgrain commented Oct 11, 2024

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 aws/jsii#4658

@berkaycagir
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants