Binds these arguments to their respective values. If there is an insufficient number of arguments, there are leftover arguments after performing the binding, or if an argument is not of the expected type, a TypeError is raised. If the given `FromArgs` includes any conversions, exceptions raised during the conversion will halt the binding and return the error.
(mut self, vm: &VirtualMachine)
| 274 | /// If the given `FromArgs` includes any conversions, exceptions raised |
| 275 | /// during the conversion will halt the binding and return the error. |
| 276 | pub fn bind<T: FromArgs>(mut self, vm: &VirtualMachine) -> PyResult<T> { |
| 277 | let given_args = self.args.len(); |
| 278 | let bound = T::from_args(vm, &mut self) |
| 279 | .map_err(|e| e.into_exception(T::arity(), given_args, vm))?; |
| 280 | |
| 281 | if !self.args.is_empty() { |
| 282 | Err(vm.new_type_error(format!( |
| 283 | "expected at most {} arguments, got {}", |
| 284 | T::arity().end(), |
| 285 | given_args, |
| 286 | ))) |
| 287 | } else if let Some(err) = self.check_kwargs_empty(vm) { |
| 288 | Err(err) |
| 289 | } else { |
| 290 | Ok(bound) |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | pub fn check_kwargs_empty(&self, vm: &VirtualMachine) -> Option<PyBaseExceptionRef> { |
| 295 | self.kwargs |
no test coverage detected