File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed
Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -136,9 +136,9 @@ impl<T: Debug> LiteralLookup<T> {
136136 }
137137 // must be an enum or bytes
138138 if let Some ( expected_py) = & self . expected_py {
139- // We don't use ? to unpack the result of get_item in the next line because unhashable
140- // inputs will produce a TypeError, which in this case we just want to treat as a
141- // validation failure
139+ // We don't use ? to unpack the result of ` get_item` in the next line because unhashable
140+ // inputs will produce a TypeError, which in this case we just want to treat equivalently
141+ // to a failed lookup
142142 if let Ok ( Some ( v) ) = expected_py. as_ref ( py) . get_item ( input) {
143143 let id: usize = v. extract ( ) . unwrap ( ) ;
144144 return Ok ( Some ( ( input, & self . values [ id] ) ) ) ;
Original file line number Diff line number Diff line change @@ -799,5 +799,7 @@ class ModelA:
799799
800800 # validation against Literal[True] fails bc of the unhashable dict
801801 # A ValidationError is raised, not a ValueError, which allows the validation against the union to continue
802- assert validator .validate_python ({'a' : 42 })
803- assert validator .validate_python (True )
802+ m = validator .validate_python ({'a' : 42 })
803+ assert isinstance (m , ModelA )
804+ assert m .a == 42
805+ assert validator .validate_python (True ) is True
You can’t perform that action at this time.
0 commit comments