Check type¶
- drain_swamp.check_type.__all__: tuple[str, str, str, str] = ("is_ok", "is_relative_required", "is_iterable_not_str", "click_bool")¶
Module exports
- drain_swamp.check_type.DEFAULT_EXTENSIONS: tuple[str, str] = (".in", ".shared.in")¶
Acceptable file extensions.
- drain_swamp.check_type.CLICK_TRUE: tuple[str, str, str, str, str, str] = ("1", "true", "t", "yes", "y", "on")¶
These are recognized to mean True. Applicable to cli boolean fields
- drain_swamp.check_type.CLICK_FALSE: tuple[str, str, str, str, str, str] = ("0", "false", "f", "no", "n", "off")¶
These are recognized to mean True. Applicable to cli boolean fields
- drain_swamp.check_type.click_bool(val=None)¶
Simulate click.Bool
- drain_swamp.check_type.is_iterable_not_str(mixed)¶
Can be iterated thru, but not the false positive, str
- drain_swamp.check_type.is_ok(test)¶
Check if non-empty str
Edge case: contains only whitespace –>
False
- drain_swamp.check_type.is_relative_required(path_relative=None, extensions=('.in', '.shared.in')) bool ¶
Check that is relative path with expected suffix
- Parameters:
path_relative¶ (pathlib.Path | None) – Default None. Intended to be a relative path
extensions¶ (collections.abc.Sequence[str]) – Default
DEFAULT_EXTENSIONS
. Acceptable file extensions.
- Returns:
If an acceptable relative path with appropriate suffix
- Return type:
- Raises:
ValueError
– Expecting at least one suffix to use to compareTypeError
– Unsupported type expected a sequence (tuple or list)