kovidgoyal/kitty · error · ValueError
{parts[1]} is not a number
Error message
{parts[1]} is not a number What it means
The right-hand side of a spacing spec must be a float or the literal 'default'; float() failure raises ValueError '{parts[1]} is not a number'.
Source
Thrown at kitty/rc/set_spacing.py:60
mapper[f'{q}-h'] = mapper[f'{q}-horizontal'] = f'{q}-left {q}-right'.split()
mapper[f'{q}-v'] = mapper[f'{q}-vertical'] = f'{q}-top {q}-bottom'.split()
for edge in ('left', 'top', 'right', 'bottom'):
mapper[f'{q}-{edge}'] = [f'{q}-{edge}']
settings: dict[str, float | None] = {}
for spec in args:
parts = spec.split('=', 1)
if len(parts) != 2:
raise ValueError(f'{spec} is not a valid setting')
which = mapper.get(parts[0].lower())
if not which:
raise ValueError(f'{parts[0]} is not a valid edge specification')
if parts[1].lower() == 'default':
val = None
else:
try:
val = float(parts[1])
except Exception:
raise ValueError(f'{parts[1]} is not a number')
for q in which:
settings[q] = val
return settings
class SetSpacing(RemoteCommand):
protocol_spec = __doc__ = """
settings+/dict.spacing: An object mapping margins/paddings using canonical form {'margin-top': 50, 'padding-left': null} etc
match_window/str: Window to change paddings and margins in
match_tab/str: Tab to change paddings and margins in
all/bool: Boolean indicating change paddings and margins everywhere or not
configured/bool: Boolean indicating whether to change the configured paddings and margins. Must be True if reset is True
"""
short_desc = 'Set window paddings and margins'
desc = (
'Set the paddings and margins for the specified windows (defaults to active window).'
' For example: :code:`margin=20` or :code:`padding-left=10` or :code:`margin-h=30`. The shorthand form sets'View on GitHub (pinned to 6d5d0c4406)
Solutions
- Use a bare number (interpreted as points) or 'default', e.g. 'margin=10' or 'margin=default'
- Remove unit suffixes like px
Example fix
# before kitten @set-spacing margin=10px # after kitten @set-spacing margin=10
Defensive patterns
Strategy: validation
Validate before calling
def valid_val(v):
try: float(v); return True
except ValueError: return v.lower()=='default' Type guard
def is_number_or_default(v: str) -> bool:
if v.lower()=='default': return True
try: float(v); return True
return False Prevention
- Never include units like px in spacing values
When it happens
Trigger: Passing non-numeric values like 'margin=wide' or 'padding=10px' (units are not accepted).
Common situations: Including units (px, em) or other text in the value.
Related errors
- {spec} is not a valid setting
- {parts[0]} is not a valid edge specification
- No colors specified
- Unknown type_of_input: {type_of_input}
- Unknown keys in multicell_command:
AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27).
Data as JSON: /api/errors/79f6368c2d8bb7cb.
Report an issue: GitHub.