Simple
SimpleParseError
Bases: ValueError, Generic[T]
Represents simple parse errors.
Source code in src/wraps/parse/simple.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | |
string: str
property
The string that could not be parsed.
type: Type[T]
property
The type parsing into which failed.
SimpleFromString
Bases: Protocol
Represents types that can be parsed from strings.
Source code in src/wraps/parse/simple.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
from_string(string: str) -> Option[Self]
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 |
|---|---|
Option[Self]
|
The parse result, |
Source code in src/wraps/parse/simple.py
43 44 45 46 47 48 49 50 51 52 53 54 55 | |
parse(string: str) -> Self
classmethod
Calls from_string and raises
SimpleParseError[Self] 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 |
|---|---|
SimpleParseError[Self]
|
In case parsing fails. |
Source code in src/wraps/parse/simple.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |