kovidgoyal/kitty · error · ValueError

Invalid underline_exclusion with non numeric value: {x}

Error message

Invalid underline_exclusion with non numeric value: {x}

What it means

Raised when underline_exclusion has a valid px/pt unit suffix but the numeric part before it cannot be parsed as a float.

Source

Thrown at kitty/options/utils.py:1194

def confirm_close(x: str) -> tuple[int, bool]:
    parts = x.split(maxsplit=1)
    num = int(parts[0])
    allow_background = len(parts) > 1 and parts[1] == 'count-background'
    return num, allow_background


def underline_exclusion(x: str) -> tuple[float, Literal['', 'px', 'pt']]:
    try:
        return float(x), ''
    except Exception:
        unit: Literal['pt', 'px'] = x[-2:]  # type: ignore
        if unit not in ('px', 'pt'):
            raise ValueError(f'Invalid underline_exclusion with unrecognized unit: {x}')
        try:
            val = float(x[:-2])
        except Exception:
            raise ValueError(f'Invalid underline_exclusion with non numeric value: {x}')
        return val, unit


def paste_actions(x: str) -> frozenset[str]:
    s = frozenset({'quote-urls-at-prompt', 'confirm', 'filter', 'confirm-if-large', 'replace-dangerous-control-codes', 'replace-newline', 'no-op'})
    q = frozenset(x.lower().split(','))
    if not q.issubset(s):
        raise ValueError(f'Invalid paste actions: {q - s}, ignoring')
    return q


def action_alias(val: str) -> Iterable[tuple[str, str]]:
    parts = val.split(maxsplit=1)
    if len(parts) > 1:
        alias_name, rest = parts
        yield alias_name, rest

View on GitHub (pinned to 6d5d0c4406)

Solutions

  1. Ensure a valid decimal number precedes the unit, e.g. 2.5px
  2. Remove stray characters before the unit

Example fix

# before
underline_exclusion abcp x
# after
underline_exclusion 2.5px
Defensive patterns

Strategy: validation

Validate before calling

import re
def valid_underline_exclusion(v: str) -> bool:
    return bool(re.fullmatch(r'-?\d+(\.\d+)?(px|pt)?', v))

Prevention

When it happens

Trigger: Values like 'px', 'abcpx', '-px', or '.px' — the last two chars are px/pt but float(x[:-2]) fails.

Common situations: Typos in the number, stray characters, or copy/paste artifacts in kitty.conf.

Related errors


AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27). Data as JSON: /api/errors/6a714a0a75dda055. Report an issue: GitHub.