Coverage for typer / _display.py: 100%
14 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-11-18 11:12 +0000
« prev ^ index » next coverage.py v7.13.1, created at 2026-11-18 11:12 +0000
1from typing import Any 1abcdefghij
3from ._click.utils import _escape_control_characters 1abcdefghij
6def describe_number_range( 1abcdefghij
7 min: int | float | None,
8 max: int | float | None,
9) -> str | None:
10 if min is None and max is None: 1abcdefghij
11 return None 1abcdefghij
12 if min is None: 1abcdefghij
13 return f"x<={max}" 1abcdefghij
14 if max is None: 1abcdefghij
15 return f"x>={min}" 1abcdefghij
16 return f"{min}<=x<={max}" 1abcdefghij
19def get_error_msg(exc: Any) -> str: 1abcdefghij
20 """Get the first validation error message with terminal controls escaped."""
21 errors = exc.errors() 1abcdefghij
22 if errors: 1abcdefghij
23 return _escape_control_characters(str(errors[0]["msg"])) 1abcdefghij
24 return _escape_control_characters(str(exc)) # pragma: no cover