MCPcopy Index your code
hub / github.com/python/mypy / convert_to_boolean

Function convert_to_boolean

mypy/config_parser.py:597–605  ·  view source on GitHub ↗

Return a boolean value translating from other types if necessary.

(value: Any | None)

Source from the content-addressed store, hash-verified

595
596
597def convert_to_boolean(value: Any | None) -> bool:
598 """Return a boolean value translating from other types if necessary."""
599 if isinstance(value, bool):
600 return value
601 if not isinstance(value, str):
602 value = str(value)
603 if value.lower() not in configparser.RawConfigParser.BOOLEAN_STATES:
604 raise ValueError(f"Not a boolean: {value}")
605 return configparser.RawConfigParser.BOOLEAN_STATES[value.lower()]
606
607
608def split_directive(s: str) -> tuple[list[str], list[str]]:

Callers 1

parse_sectionFunction · 0.85

Calls 4

isinstanceFunction · 0.85
strClass · 0.85
ValueErrorClass · 0.85
lowerMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…