Normal
ParseError
Bases: ValueError
, Generic[T, E]
Represents parse errors.
Source code in src/wraps/parse/normal.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
|
string: str
property
The string that could not be parsed.
type: Type[T]
property
The type parsing into which failed.
error: E
property
The error returned by the
from_string
function.
FromString
Bases: Protocol[E]
Represents types that can be parsed from strings.
Source code in src/wraps/parse/normal.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
|
from_string(string: str) -> Result[Self, E]
classmethod
Parses the given string to return some value of type Self
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
string |
str
|
The string to parse. |
required |
Returns:
Type | Description |
---|---|
Result[Self, E]
|
The parse result, |
Source code in src/wraps/parse/normal.py
52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
parse(string: str) -> Self
classmethod
Calls from_string
and raises
ParseError[Self, E]
if parsing fails.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
string |
str
|
The string to parse. |
required |
Returns:
Type | Description |
---|---|
Self
|
The parsed value. |
Raises:
Type | Description |
---|---|
ParseError[Self, E]
|
In case parsing fails. |
Source code in src/wraps/parse/normal.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
|