MCPcopy Create free account
hub / github.com/imrahulr/hat / str2bool

Function str2bool

core/utils/utils.py:50–61  ·  view source on GitHub ↗

Parse boolean using argument parser.

(v)

Source from the content-addressed store, hash-verified

48
49
50def str2bool(v):
51 """
52 Parse boolean using argument parser.
53 """
54 if isinstance(v, bool):
55 return v
56 if v.lower() in ('yes', 'true', 't', 'y', '1'):
57 return True
58 elif v.lower() in ('no', 'false', 'f', 'n', '0'):
59 return False
60 else:
61 raise argparse.ArgumentTypeError('Boolean value expected.')
62
63def str2float(x):
64 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…