Skip to content

Update pre commit #5889

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

Closed
wants to merge 2 commits into from
Closed
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: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ repos:
language_version: '3.11'
args: ['--profile', 'black', '--filter-files']
- repo: https://github.com/psf/black
rev: '24.1.1'
rev: '25.1.0'
hooks:
- id: black
- repo: https://github.com/hadialqattan/pycln # removes unused imports
rev: v2.3.0
rev: v2.5.0
hooks:
- id: pycln
language_version: '3.11'
Expand Down
17 changes: 8 additions & 9 deletions src/textual/widgets/_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class Input(ScrollView):
| ctrl+k | Delete everything to the right of the cursor. |
| ctrl+x | Cut selected text. |
| ctrl+c | Copy selected text. |
| ctrl+v | Paste text from the clipboard. |
| ctrl+v | Paste text from the clipboard. |
"""

COMPONENT_CLASSES: ClassVar[set[str]] = {
Expand Down Expand Up @@ -187,9 +187,9 @@ class Input(ScrollView):
}

&:focus {
border: tall $border;
border: tall $border;
background-tint: $foreground 5%;

}
&>.input--cursor {
background: $input-cursor-background;
Expand All @@ -207,12 +207,12 @@ class Input(ScrollView):
}
&.-invalid:focus {
border: tall $error;
}
}

&:ansi {
background: ansi_default;
color: ansi_default;
&>.input--cursor {
&>.input--cursor {
text-style: reverse;
}
&>.input--placeholder, &>.input--suggestion {
Expand All @@ -224,8 +224,8 @@ class Input(ScrollView):
}
&.-invalid:focus {
border: tall ansi_red;
}
}

}
}

Expand Down Expand Up @@ -417,8 +417,7 @@ def __init__(
```
"""
self._reactive_valid_empty = valid_empty
self._valid = True

self._valid = not (input and not valid_empty)
self.restrict = restrict
if type not in _RESTRICT_TYPES:
raise ValueError(
Expand Down
17 changes: 17 additions & 0 deletions tests/input/test_input_empty_valid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from textual.app import App, ComposeResult
from textual.widgets import Input


class InputApp(App):

def compose(self) -> ComposeResult:
yield Input(valid_empty=False)


async def test_cut():
"""Check that cut removes text and places it in the clipboard."""
app = InputApp()
async with app.run_test() as pilot:
input = app.query_one(Input)
assert input.value == ""
assert not input.is_valid
Loading