Skip to content

Commit d023d05

Browse files
committed
add comments
1 parent e5402f5 commit d023d05

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/validators/enum_.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,12 @@ impl EnumValidateValue for PlainEnumValidator {
174174
Ok(None) => {
175175
if !strict {
176176
if let Some(py_input) = input.as_python() {
177+
// necessary for compatibility with 2.6, where str and int subclasses are allowed
177178
if py_input.is_instance_of::<PyString>() {
178179
return Ok(lookup.validate_str(input, false)?.map(|v| v.clone_ref(py)));
179180
} else if py_input.is_instance_of::<PyInt>() {
180181
return Ok(lookup.validate_int(py, input, false)?.map(|v| v.clone_ref(py)));
182+
// necessary for compatibility with 2.6, where float values are allowed for int enums in lax mode
181183
} else if py_input.is_instance_of::<PyFloat>() {
182184
return Ok(lookup.validate_int(py, input, false)?.map(|v| v.clone_ref(py)));
183185
}

0 commit comments

Comments
 (0)