File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ This library adheres to
1616 (`#432 <https://github.com/agronholm/typeguard/issues/432 >`_, PR by Yongxin Wang)
1717- Fixed detection of optional fields (``NotRequired[...] ``) in ``TypedDict `` when using
1818 forward references (`#424 <https://github.com/agronholm/typeguard/issues/424 >`_)
19+ - Fixed mapping checks against Django's ``MultiValueDict ``
20+ (`#419 <https://github.com/agronholm/typeguard/issues/419 >`_)
1921
2022**4.1.5 ** (2023-09-11)
2123
Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3- from collections .abc import Collection
3+ from collections .abc import Iterable
44from dataclasses import dataclass
55from enum import Enum , auto
66from typing import TYPE_CHECKING , TypeVar
@@ -49,11 +49,11 @@ class CollectionCheckStrategy(Enum):
4949 FIRST_ITEM = auto ()
5050 ALL_ITEMS = auto ()
5151
52- def iterate_samples (self , collection : Collection [T ]) -> Collection [T ]:
52+ def iterate_samples (self , collection : Iterable [T ]) -> Iterable [T ]:
5353 if self is CollectionCheckStrategy .FIRST_ITEM :
54- if len ( collection ) :
54+ try :
5555 return [next (iter (collection ))]
56- else :
56+ except StopIteration :
5757 return ()
5858 else :
5959 return collection
Original file line number Diff line number Diff line change @@ -433,6 +433,14 @@ def test_bad_value_type_full_check(self):
433433 collection_check_strategy = CollectionCheckStrategy .ALL_ITEMS ,
434434 ).match ("value of key 'y' of dict is not an instance of int" )
435435
436+ def test_custom_dict_generator_items (self ):
437+ class CustomDict (dict ):
438+ def items (self ):
439+ for key in self :
440+ yield key , self [key ]
441+
442+ check_type (CustomDict (a = 1 ), Dict [str , int ])
443+
436444
437445class TestTypedDict :
438446 @pytest .mark .parametrize (
You can’t perform that action at this time.
0 commit comments