Textualize/textual · error · ValueError
Input type must be one of {friendly_list(_RESTRICT_TYPES.key
Error message
Input type must be one of {friendly_list(_RESTRICT_TYPES.keys())}; not {type!r} What it means
A ValueError raised in Input.__init__ when the type argument is not one of the keys of _RESTRICT_TYPES (typically 'text', 'integer', 'number', 'password' — the exact set depends on the Textual version). Input uses this enum to configure input filtering/validation, so unknown strings are rejected at construction.
Source
Thrown at src/textual/widgets/_input.py:441
)
"""Set with event names to do input validation on.
Validation can only be performed on blur, on input changes and on input submission.
Example:
This creates an `Input` widget that only gets validated when the value
is submitted explicitly:
```py
input = Input(validate_on=["submitted"])
```
"""
self._reactive_valid_empty = valid_empty
self._valid = True
self.restrict = restrict
if type not in _RESTRICT_TYPES:
raise ValueError(
f"Input type must be one of {friendly_list(_RESTRICT_TYPES.keys())}; not {type!r}"
)
self.type = type
self.max_length = max_length
if not self.validators:
from textual.validation import Integer, Number
if self.type == "integer":
self.validators.append(Integer())
elif self.type == "number":
self.validators.append(Number())
self._selecting = False
"""True if the user is selecting text with the mouse."""
self._initial_value = True
"""Indicates if the value has been set for the first time yet."""
if value is not None:View on GitHub (pinned to 06dbeef4bb)
Solutions
- Use an exact allowed literal, e.g. Input(type='integer').
- Validate config-driven values against the allowed set before constructing Input.
- Check the installed version's _RESTRICT_TYPES keys (from textual.widgets._input import _RESTRICT_TYPES) when unsure.
- Omit type= entirely for plain text input.
Example fix
# before field = Input(type='int') # after field = Input(type='integer')
Defensive patterns
Strategy: validation
Validate before calling
from textual.widgets._input import _RESTRICT_TYPES
assert input_type in _RESTRICT_TYPES, f'bad type {input_type!r}'
Input(type=input_type) Type guard
from textual.widgets._input import _RESTRICT_TYPES
def is_valid_input_type(t: object) -> bool:
return isinstance(t, str) and t in _RESTRICT_TYPES Prevention
- Use exact literals like 'integer', 'number', 'text', 'password'
- Validate config-driven type strings against _RESTRICT_TYPES
- Check docs for the installed Textual version
When it happens
Trigger: Passing type='int' or type='Integer' (wrong casing/spelling) to Input; passing a custom string not in _RESTRICT_TYPES; upgrading Textual where the allowed set changed.
Common situations: Copy-pasting Input(type=...) snippets from older docs/examples; dynamic type selection from config where an invalid value slips in; typos like 'interger'.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- {self.name} must be one of {friendly_list(self._valid_values
- unknown word {word!r} in style flags
- More values provided than there are columns.
- Template must contain at least one non-separator character
- Value does not match template!
AI-assisted analysis of Textualize/textual@06dbeef4bb (2026-08-27).
Data as JSON: /api/errors/0ad827c2eca9ede1.
Report an issue: GitHub.