You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.4.1
Python version
3.10.12
What happened?
When I try to check the type of a dictionary defined as Dict[str, str], check_type is correct only if the wrong value is first. See the xample.
The same issue occurs, when the type to check is defined as dict[str.str].
>>> from typeguard import check_type
>>> A = {"int": 1}
>>> B = {"str": "hello world", "int": 1}
>>> from typing import Dict
>>> type_to_check = Dict[str, str]
>>> check_type(A, type_to_check)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/marek/it4i/Lexis/api-v2/env/lib/python3.10/site-packages/typeguard/_functions.py", line 106, in check_type
check_type_internal(value, expected_type, memo)
File "/home/marek/it4i/Lexis/api-v2/env/lib/python3.10/site-packages/typeguard/_checkers.py", line 861, in check_type_internal
checker(value, origin_type, args, memo)
File "/home/marek/it4i/Lexis/api-v2/env/lib/python3.10/site-packages/typeguard/_checkers.py", line 242, in check_mapping
check_type_internal(v, value_type, memo)
File "/home/marek/it4i/Lexis/api-v2/env/lib/python3.10/site-packages/typeguard/_checkers.py", line 866, in check_type_internal
raise TypeCheckError(f"is not an instance of {qualified_name(origin_type)}")
typeguard.TypeCheckError: value of key 'int' of dict is not an instance of str
>>> check_type(B, type_to_check)
{'str': 'hello world', 'int': 1}
>>>
How can we reproduce the bug?
Try same snippet as I sent in the issue description.
The text was updated successfully, but these errors were encountered:
You didn't check the existing issues. This was among the two pinned issues: #418
As this is causing so much trouble, I'm reversing this logic in the next major release.
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.4.1
Python version
3.10.12
What happened?
When I try to check the type of a dictionary defined as Dict[str, str], check_type is correct only if the wrong value is first. See the xample.
The same issue occurs, when the type to check is defined as dict[str.str].
How can we reproduce the bug?
Try same snippet as I sent in the issue description.
The text was updated successfully, but these errors were encountered: