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

variable-length tuple of homogeneous type isn't working #360

Closed
2 tasks done
ManuelZierl opened this issue May 22, 2023 · 1 comment
Closed
2 tasks done

variable-length tuple of homogeneous type isn't working #360

ManuelZierl opened this issue May 22, 2023 · 1 comment
Labels

Comments

@ManuelZierl
Copy link

Things to check first

  • I have searched the existing issues and didn't find my bug already reported there

  • I have checked that my bug is still present in the latest release

Typeguard version

4.0.0

Python version

3.9

What happened?

from python typing doc

To specify a variable-length tuple of homogeneous type, use literal ellipsis, e.g. Tuple[int, ...]. A plain [Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple) is equivalent to Tuple[Any, ...], and in turn to [tuple](https://docs.python.org/3/library/stdtypes.html#tuple).

but this doesnt fail:

from typeguard import check_type

check_type((1, "a"), tuple[int, ...])

How can we reproduce the bug?

from typeguard import check_type

check_type((1, "a"), tuple[int, ...])
@ManuelZierl
Copy link
Author

ok found the soltion. The behavior is intended for performance reason but to check all types in tuple i need to do

from typing import Tuple

from typeguard import check_type, CollectionCheckStrategy

check_type((1, 1, "a",), Tuple[int, ...], collection_check_strategy=CollectionCheckStrategy.ALL_ITEMS)

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

No branches or pull requests

1 participant