Skip to content

Commit 9e196fe

Browse files
committed
wip failing commit
1 parent c1e50d2 commit 9e196fe

File tree

4 files changed

+3
-123
lines changed

4 files changed

+3
-123
lines changed

src/input/input_abstract.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -182,32 +182,6 @@ pub trait Input<'a>: fmt::Debug + ToPyObject {
182182
self.strict_tuple()
183183
}
184184

185-
fn validate_set(&'a self, strict: bool) -> ValResult<GenericCollection<'a>> {
186-
if strict {
187-
self.strict_set()
188-
} else {
189-
self.lax_set()
190-
}
191-
}
192-
fn strict_set(&'a self) -> ValResult<GenericCollection<'a>>;
193-
#[cfg_attr(has_no_coverage, no_coverage)]
194-
fn lax_set(&'a self) -> ValResult<GenericCollection<'a>> {
195-
self.strict_set()
196-
}
197-
198-
fn validate_frozenset(&'a self, strict: bool) -> ValResult<GenericCollection<'a>> {
199-
if strict {
200-
self.strict_frozenset()
201-
} else {
202-
self.lax_frozenset()
203-
}
204-
}
205-
fn strict_frozenset(&'a self) -> ValResult<GenericCollection<'a>>;
206-
#[cfg_attr(has_no_coverage, no_coverage)]
207-
fn lax_frozenset(&'a self) -> ValResult<GenericCollection<'a>> {
208-
self.strict_frozenset()
209-
}
210-
211185
fn validate_iter(&self) -> ValResult<GenericIterator>;
212186

213187
fn validate_date(&self, strict: bool) -> ValResult<EitherDate> {

src/input/input_json.rs

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -199,30 +199,6 @@ impl<'a> Input<'a> for JsonInput {
199199
self.validate_tuple(false)
200200
}
201201

202-
fn validate_set(&'a self, _strict: bool) -> ValResult<GenericCollection<'a>> {
203-
// we allow a list here since otherwise it would be impossible to create a set from JSON
204-
match self {
205-
JsonInput::Array(a) => Ok(a.into()),
206-
_ => Err(ValError::new(ErrorType::SetType, self)),
207-
}
208-
}
209-
#[cfg_attr(has_no_coverage, no_coverage)]
210-
fn strict_set(&'a self) -> ValResult<GenericCollection<'a>> {
211-
self.validate_set(false)
212-
}
213-
214-
fn validate_frozenset(&'a self, _strict: bool) -> ValResult<GenericCollection<'a>> {
215-
// we allow a list here since otherwise it would be impossible to create a frozenset from JSON
216-
match self {
217-
JsonInput::Array(a) => Ok(a.into()),
218-
_ => Err(ValError::new(ErrorType::FrozenSetType, self)),
219-
}
220-
}
221-
#[cfg_attr(has_no_coverage, no_coverage)]
222-
fn strict_frozenset(&'a self) -> ValResult<GenericCollection<'a>> {
223-
self.validate_frozenset(false)
224-
}
225-
226202
fn extract_iterable(&'a self) -> ValResult<super::any_iterable::GenericIterable<'a>> {
227203
match self {
228204
JsonInput::Array(a) => Ok(super::any_iterable::GenericIterable::JsonArray(a)),
@@ -414,24 +390,6 @@ impl<'a> Input<'a> for String {
414390
self.validate_tuple(false)
415391
}
416392

417-
#[cfg_attr(has_no_coverage, no_coverage)]
418-
fn validate_set(&'a self, _strict: bool) -> ValResult<GenericCollection<'a>> {
419-
Err(ValError::new(ErrorType::SetType, self))
420-
}
421-
#[cfg_attr(has_no_coverage, no_coverage)]
422-
fn strict_set(&'a self) -> ValResult<GenericCollection<'a>> {
423-
self.validate_set(false)
424-
}
425-
426-
#[cfg_attr(has_no_coverage, no_coverage)]
427-
fn validate_frozenset(&'a self, _strict: bool) -> ValResult<GenericCollection<'a>> {
428-
Err(ValError::new(ErrorType::FrozenSetType, self))
429-
}
430-
#[cfg_attr(has_no_coverage, no_coverage)]
431-
fn strict_frozenset(&'a self) -> ValResult<GenericCollection<'a>> {
432-
self.validate_frozenset(false)
433-
}
434-
435393
fn validate_iter(&self) -> ValResult<GenericIterator> {
436394
Ok(string_to_vec(self).into())
437395
}

src/input/input_python.rs

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -459,58 +459,6 @@ impl<'a> Input<'a> for PyAny {
459459
}
460460
}
461461

462-
fn strict_set(&'a self) -> ValResult<GenericCollection<'a>> {
463-
if let Ok(set) = self.downcast::<PySet>() {
464-
Ok(set.into())
465-
} else {
466-
Err(ValError::new(ErrorType::SetType, self))
467-
}
468-
}
469-
470-
fn lax_set(&'a self) -> ValResult<GenericCollection<'a>> {
471-
if let Ok(set) = self.downcast::<PySet>() {
472-
Ok(set.into())
473-
} else if let Ok(list) = self.downcast::<PyList>() {
474-
Ok(list.into())
475-
} else if let Ok(tuple) = self.downcast::<PyTuple>() {
476-
Ok(tuple.into())
477-
} else if let Ok(frozen_set) = self.downcast::<PyFrozenSet>() {
478-
Ok(frozen_set.into())
479-
} else if let Some(collection) = extract_dict_iter!(self) {
480-
Ok(collection)
481-
} else if let Some(collection) = extract_shared_iter!(PyTuple, self) {
482-
Ok(collection)
483-
} else {
484-
Err(ValError::new(ErrorType::SetType, self))
485-
}
486-
}
487-
488-
fn strict_frozenset(&'a self) -> ValResult<GenericCollection<'a>> {
489-
if let Ok(set) = self.downcast::<PyFrozenSet>() {
490-
Ok(set.into())
491-
} else {
492-
Err(ValError::new(ErrorType::FrozenSetType, self))
493-
}
494-
}
495-
496-
fn lax_frozenset(&'a self) -> ValResult<GenericCollection<'a>> {
497-
if let Ok(frozen_set) = self.downcast::<PyFrozenSet>() {
498-
Ok(frozen_set.into())
499-
} else if let Ok(set) = self.downcast::<PySet>() {
500-
Ok(set.into())
501-
} else if let Ok(list) = self.downcast::<PyList>() {
502-
Ok(list.into())
503-
} else if let Ok(tuple) = self.downcast::<PyTuple>() {
504-
Ok(tuple.into())
505-
} else if let Some(collection) = extract_dict_iter!(self) {
506-
Ok(collection)
507-
} else if let Some(collection) = extract_shared_iter!(PyTuple, self) {
508-
Ok(collection)
509-
} else {
510-
Err(ValError::new(ErrorType::FrozenSetType, self))
511-
}
512-
}
513-
514462
fn extract_iterable(&'a self) -> ValResult<super::any_iterable::GenericIterable<'a>> {
515463
// Handle concrete non-overlapping types first, then abstract types
516464
if let Ok(iterable) = self.downcast::<PyList>() {

src/validators/dict.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl Validator for DictValidator {
150150

151151
let generic_iterable = input
152152
.extract_iterable()
153-
.map_err(|_| ValError::new(ErrorType::ListType, input))?;
153+
.map_err(|_| ValError::new(ErrorType::DictType, input))?;
154154
let output = match (generic_iterable, strict) {
155155
// Always allow actual dicts or JSON objects
156156
(GenericIterable::Dict(iter), _) => iterator::validate_mapping(
@@ -197,9 +197,9 @@ impl Validator for DictValidator {
197197
false,
198198
)
199199
}
200-
Err(_) => return Err(ValError::new(ErrorType::ListType, input)),
200+
Err(_) => return Err(ValError::new(ErrorType::DictType, input)),
201201
},
202-
_ => return Err(ValError::new(ErrorType::ListType, input)),
202+
_ => return Err(ValError::new(ErrorType::DictType, input)),
203203
}?;
204204

205205
Ok(output.into_py(py))

0 commit comments

Comments
 (0)