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.1.5
Python version
3.11
What happened?
I'm attempting to force validation on my function arguments, one of which is itself a list of dicts with known keys. Typeguard only seems to be performing type validation on the first element of the list of dicts. I'm stumped as to why this is happening.
fromtypingimportTypedDict, Unpack, Required, NotRequired, Listfromtypeguardimportcheck_typeclassentitySearch_tag_param_type(TypedDict):
key: strvalue: strclassentitySearch_query_param_types(TypedDict, total=False):
alertSeverity: strdomain: strname: strtags: List[entitySearch_tag_param_type]
type: strclassmyClass():
# inits etc ...defconstruct_entitySearch_querystring(self, **kwargs):
print(kwargs)
check_type(kwargs, entitySearch_query_param_types)
defmain():
# tagsDict = [{'key':"12",'value':'y'}] # passes# tagsDict = [{'snarfblat':'x', 'dinglehopper':'y'}] # fails with:# File "/Users/devin.nasar/project/.venv/lib/python3.11/site-packages/typeguard/_checkers.py", line 256, in check_typed_dict# raise TypeCheckError(f"has unexpected extra key(s): {keys_formatted}")# typeguard.TypeCheckError: item 0 of value of key 'tags' of dict has unexpected extra key(s): "dinglehopper", "snarfblat"tagsDict=[ # passes again, what gives?
{'key':"12",'value':'y'}, # valid
{'snarfblat':'x', 'dinglehopper':'y'}, # invalid keys, should raise
{'bangarang':1, 'blargh':'x'}, # invalid values, should raise"teststring"# not a dict, should raise
]
myClass.construct_entitySearch_querystring(
alertSeverity="12",
tags=tagsDict
)
if__name__=="__main__":
main()
How can we reproduce the bug?
Run the code in the bug report.
The text was updated successfully, but these errors were encountered:
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.1.5
Python version
3.11
What happened?
I'm attempting to force validation on my function arguments, one of which is itself a list of dicts with known keys. Typeguard only seems to be performing type validation on the first element of the list of dicts. I'm stumped as to why this is happening.
How can we reproduce the bug?
Run the code in the bug report.
The text was updated successfully, but these errors were encountered: