Skip to content

Commit 3531f74

Browse files
authored
feat: add pre-commit (#24)
* add pre-commit * bump isort pre-commit hook
1 parent c540f72 commit 3531f74

File tree

5 files changed

+34
-8
lines changed

5 files changed

+34
-8
lines changed

.pre-commit-config.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.1.0
4+
hooks:
5+
- id: check-toml
6+
- id: end-of-file-fixer
7+
- id: trailing-whitespace
8+
- repo: https://github.com/PyCQA/isort
9+
rev: 5.10.1
10+
hooks:
11+
- id: isort
12+
- repo: https://github.com/psf/black
13+
rev: 22.3.0
14+
hooks:
15+
- id: black
16+
language_version: python3
17+
- repo: https://github.com/pre-commit/mirrors-mypy
18+
rev: v0.941
19+
hooks:
20+
- id: mypy
21+
- repo: https://github.com/PyCQA/flake8
22+
rev: 4.0.1
23+
hooks:
24+
- id: flake8
25+
args: ["--ignore=E203,W503"]

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pre-commit

src/textual_inputs/events.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
HANDLER_SAFE = ascii_lowercase + digits + "_"
1111

1212

13-
class InputOnChange(Message, bubble=True):
13+
class InputOnChange(Message, bubble=True): # type: ignore
1414
"""Generic on change message for inputs"""
1515

1616
_handler: str = "handle_input_on_change"
1717

1818

19-
class InputOnFocus(Message, bubble=True):
19+
class InputOnFocus(Message, bubble=True): # type: ignore
2020
"""Generic on focus message for inputs"""
2121

2222
_handler: str = "handle_input_on_focus"
@@ -62,6 +62,6 @@ def make_message_class(handler_name: str) -> Message:
6262
)
6363
name = handler_name.lower()[7:]
6464
t = type(name, (Message,), {})
65-
t._handler = handler_name
66-
t.bubble = True
65+
t._handler = handler_name # type: ignore
66+
t.bubble = True # type: ignore
6767
return t

src/textual_inputs/integer_input.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ def _render_text_with_cursor(self) -> List[Union[str, Tuple[str, Style]]]:
195195
and cursor.
196196
"""
197197
value = self._value_as_str
198+
segments: List[Union[str, Tuple[str, Style]]]
198199

199200
if len(value) == 0:
200201
segments = [self.cursor]

src/textual_inputs/text_input.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,20 @@
33
"""
44
from __future__ import annotations
55

6-
from typing import TYPE_CHECKING, List, Optional, Tuple, Union
6+
from typing import TYPE_CHECKING, Any, List, Optional, Tuple, Union
77

88
import rich.box
9+
from rich.console import Console
910
from rich.panel import Panel
1011
from rich.style import Style
12+
from rich.syntax import Syntax
1113
from rich.text import Text
1214
from textual import events
1315
from textual.reactive import Reactive
1416
from textual.widget import Widget
1517

1618
from textual_inputs.events import InputOnChange, InputOnFocus, make_message_class
1719

18-
from rich.console import Console
19-
from rich.syntax import Syntax
20-
2120
if TYPE_CHECKING:
2221
from rich.console import RenderableType
2322

0 commit comments

Comments
 (0)