def test_get_parser(): assert get_parser(bool) == parse_bool assert get_parser(str) == str # Note: I'd like to do this with a lambda, but flake8 has a bug where it # complains about assigning lambdas to a varaible and doing "noqa" doesn't # work. def foo(): pass assert get_parser(foo) == foo
def __call__(self, val): val_parser = get_parser(self.val_parser) out = [] for part in val.split(','): k, v = part.split(':') out.append((k, val_parser(v))) return out
def __call__(self, val): val_parser = get_parser(self.val_parser) out = [] for part in val.split(","): k, v = part.split(":") out.append((k, val_parser(v))) return out
def __call__(self, val): val = val.strip() val_parser = get_parser(self.val_parser) out = {} if not val: return out for part in val.split(","): k, v = part.split(":") out[k.strip()] = val_parser(v.strip()) return out