def get_type(value): """Infer type from value.""" if isinstance(value, string_types): return Type.STRING elif isinstance(value, (int, float)): return Type.NUMBER elif isinstance(value, bool): return Type.BOOLEAN raise exceptions.Error(f'Value of unknown type: {value}')
def get_type(value): """Infer type from value.""" if isinstance(value, string_types): return TypeCodeAndValue(Type.STRING, value, False) elif isinstance(value, (int, float)): return TypeCodeAndValue(Type.NUMBER, value, False) elif isinstance(value, bool): return TypeCodeAndValue(Type.BOOLEAN, value, False) elif is_iterable(value): return TypeCodeAndValue(Type.STRING, value, True) raise exceptions.Error(f'Value of unknown type: {value}')
def g(self, *args, **kwargs): if self._results is None: raise exceptions.Error('Called before `execute`') return f(self, *args, **kwargs)
def g(self, *args, **kwargs): if self.closed: raise exceptions.Error(f'{self.__class__.__name__} already closed') return f(self, *args, **kwargs)