Skip to content

Commit 6d4ee4b

Browse files
committed
docstring example
1 parent adf6d1c commit 6d4ee4b

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/textual/validation.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def __rich_repr__(self) -> rich.repr.Result: # pragma: no cover
110110

111111

112112
class Validator(ABC):
113-
"""Base class for the validation of string values.
113+
'''Base class for the validation of string values.
114114
115115
Commonly used in conjunction with the `Input` widget, which accepts a
116116
list of validators via its constructor. This validation framework can also be used to validate any 'stringly-typed'
@@ -120,13 +120,18 @@ class Validator(ABC):
120120
121121
Example:
122122
```python
123+
def is_palindrome(value: str) -> bool:
124+
"""Check has string has the same code points left to right, as right to left."""
125+
return value == value[::-1]
126+
123127
class Palindrome(Validator):
124128
def validate(self, value: str) -> ValidationResult:
125-
def is_palindrome(value: str) -> bool:
126-
return value == value[::-1]
127-
return self.success() if is_palindrome(value) else self.failure("Not palindrome!")
129+
if is_palindrome(value):
130+
return self.success()
131+
else:
132+
return self.failure("Not a palindrome!")
128133
```
129-
"""
134+
'''
130135

131136
def __init__(self, failure_description: str | None = None) -> None:
132137
self.failure_description = failure_description

0 commit comments

Comments
 (0)