espnet3.contract.kinds.text.TextKind
Less than 1 minute
espnet3.contract.kinds.text.TextKind
class espnet3.contract.kinds.text.TextKind
Bases: Kind
text: a str; pieces append.
check(value, field, model, , output)
Require a str; return it unchanged.
- Parameters:
- value – What the caller gave, or what the hook returned.
- field – The declaration, for the name in the error.
- model – Unused; text needs nothing from the model.
- output – Whether
valueis a hook’s result.
- Returns:
valueitself. - Raises:TypeError – If
valueis not astr.
####### Examples
>>> TextKind().check("hello", Field("text", "text"), model, output=False)
'hello'
>>> TextKind().check(7, Field("text", "text"), model, output=True)
Traceback (most recent call last):
TypeError: 'text' returned as int, must be strjoin(first, second)
Append the text.
- Parameters:
- first – The text gathered so far.
- second – The text that follows.
- Returns: The two strings joined.
####### Examples
>>> TextKind().join("a", "b")
'ab'normalizers = {'strip': <method 'strip' of 'str' objects>, 'to_lower': <method 'lower' of 'str' objects>, 'to_upper': <method 'upper' of 'str' objects>}
