Skip to content

typeguard v4.2.1 prints out non-runtime protocol messages #4981

@polothy

Description

@polothy

Describe the bug

Recently upgraded [email protected] in a Python based project. This caused typeguard to upgrade from v2.13.3 to v4.2.1. On synth, getting many of these messages:

/path/to/.venv/lib/python3.13/site-packages/aws_cdk/aws_events/__init__.py:411: UserWarning: Typeguard cannot check the IRuleTarget protocol because it is a non-runtime protocol. If you would like to type check this protocol, please use @typing.runtime_checkable
  typeguard.check_type(value=value, expected_type=expected_type, collection_check_strategy=typeguard.CollectionCheckStrategy.ALL_ITEMS) # type:ignore

Might be related to #4658 but seems like that's another problem with typeguard (incompatible interfaces vs runtime protocol).

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

No messages from typeguard.

Current Behavior

typeguard prints these message:

/path/to/.venv/lib/python3.13/site-packages/aws_cdk/aws_events/__init__.py:411: UserWarning: Typeguard cannot check the IRuleTarget protocol because it is a non-runtime protocol. If you would like to type check this protocol, please use @typing.runtime_checkable
  typeguard.check_type(value=value, expected_type=expected_type, collection_check_strategy=typeguard.CollectionCheckStrategy.ALL_ITEMS) # type:ignore

Reproduction Steps

Use typeguard v4.2.1 in a Python CDK project, using latest aws-cdk-lib

Possible Solution

Workaround: pin typeguard to 2.13.3.

Additional Information/Context

No response

SDK version used

1.119.0

Environment details (OS name and version, etc.)

macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.p1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions