Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input validators crash fix #4868

Merged
merged 3 commits into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- Added `tooltip` to Binding https://github.com/Textualize/textual/pull/4859

### Fixed

- Fix crash when `validate_on` value isn't a set https://github.com/Textualize/textual/pull/4868

## [0.76.0]

### Changed
Expand Down
4 changes: 2 additions & 2 deletions src/textual/widgets/_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import re
from dataclasses import dataclass
from typing import TYPE_CHECKING, ClassVar, Iterable, cast
from typing import TYPE_CHECKING, ClassVar, Iterable

from rich.cells import cell_len, get_character_cell_size
from rich.console import Console, ConsoleOptions, RenderableType
Expand Down Expand Up @@ -301,7 +301,7 @@ def __init__(
self.validators = list(validators)

self.validate_on: set[str] = (
(_POSSIBLE_VALIDATE_ON_VALUES & cast("set[str]", validate_on))
(_POSSIBLE_VALIDATE_ON_VALUES & set(validate_on))
if validate_on is not None
else _POSSIBLE_VALIDATE_ON_VALUES
)
Expand Down
7 changes: 4 additions & 3 deletions tests/input/test_input_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,11 @@ async def test_on_blur_triggers_validation():
"validate_on",
[
set(),
[],
{"blur"},
{"submitted"},
{"blur", "submitted"},
{"fried", "garbage"},
["submitted"],
["blur", "submitted"],
["fried", "garbage"],
],
)
async def test_validation_on_changed_should_not_happen(validate_on):
Expand Down
Loading