7.2. Type Classes¶
7.2.1. Boolean Type¶
-
class
typepy.
Bool
(value: Any, strict_level: int = 2, **kwargs)[source]¶ For each member methods, the result matrix for each
strict_level
is as follows. Column headers (exceptMethod
column) indicate input data tovalue
argument of a method in theMethod
column. For each cell shows the output of the method.¶ Method True
"true"
1 is_type()
True
True
True
validate()
NOP [1] NOP [1] NOP [1] convert()
True
True
True
try_convert()
True
True
True
force_convert()
True
True
True
¶ Method True
"true"
1 is_type()
True
True
False
validate()
NOP [1] NOP [1] E [2] convert()
True
True
E [2] try_convert()
True
True
None
force_convert()
True
True
True
¶ Method True
"true"
1 is_type()
True
False
False
validate()
NOP [1] E [2] E [2] convert()
True
E [2] E [2] try_convert()
True
None
None
force_convert()
True
True
True
-
strict_level
¶ Represents how much strict to detect the value type. Higher
strict_level
means that stricter type check.
-
convert
()¶ Returns: Converted value. Raises: typepy.TypeConversionError – If the value cannot convert.
-
force_convert
()¶ Returns: Converted value. Raises: typepy.TypeConversionError – If the value cannot convert.
-
7.2.2. Date Time Type¶
-
class
typepy.
DateTime
(value: Any, strict_level: int = 2, **kwargs)[source]¶ For each member methods, the result matrix for each
strict_level
is as follows. Column headers (exceptMethod
column) indicate input data tovalue
argument of a method in theMethod
column. For each cell shows the output of the method.¶ Method datetime(2017, 1, 23, 4, 56)
"2017-01-22T04:56:00+0900"
1485685623
"1485685623"
is_type()
True
True
True
True
validate()
NOP [1] NOP [1] NOP [1] NOP [1] convert()
2017-01-23 04:56:00 2017-01-22 04:56:00+09:00 2017-01-29 19:27:03 2017-01-29T19:27:03 try_convert()
2017-01-23 04:56:00 2017-01-22 04:56:00+09:00 2017-01-29 19:27:03 2017-01-29T19:27:03 force_convert()
2017-01-23 04:56:00 2017-01-22 04:56:00+09:00 2017-01-29 19:27:03 2017-01-29T19:27:03 ¶ Method datetime(2017, 1, 23, 4, 56)
"2017-01-22T04:56:00+0900"
1485685623
"1485685623"
is_type()
True
True
False
False
validate()
NOP [1] NOP [1] E [2] E [2] convert()
2017-01-23 04:56:00 2017-01-22 04:56:00+09:00 E [2] E [2] try_convert()
2017-01-23 04:56:00 2017-01-22 04:56:00+09:00 None
None
force_convert()
2017-01-23 04:56:00 2017-01-22 04:56:00+09:00 2017-01-29 19:27:03 2017-01-29T19:27:03 ¶ Method datetime(2017, 1, 23, 4, 56)
"2017-01-22T04:56:00+0900"
1485685623
"1485685623"
is_type()
True
False
False
False
validate()
NOP [1] E [2] E [2] E [2] convert()
2017-01-23 04:56:00 E [2] E [2] E [2] try_convert()
2017-01-23 04:56:00 None
None
None
force_convert()
2017-01-23 04:56:00 2017-01-22 04:56:00+09:00 2017-01-29 19:27:03 2017-01-29T19:27:03 strict_level
- Represents how much strict to detect the value type. Higher
strict_level
means that stricter type check.
-
convert
()¶ Returns: Converted value. Raises: typepy.TypeConversionError – If the value cannot convert.
-
force_convert
()¶ Returns: Converted value. Raises: typepy.TypeConversionError – If the value cannot convert.
7.2.3. Dictionary Type¶
-
class
typepy.
Dictionary
(value: Any, strict_level: int = 1, **kwargs)[source]¶ For each member methods, the result matrix for each
strict_level
is as follows. Column headers (exceptMethod
column) indicate input data tovalue
argument of a method in theMethod
column. For each cell shows the output of the method.¶ Method {}
{"a": 1}
(("a", 1), )
is_type()
True
True
True
validate()
NOP [1] NOP [1] NOP [1] convert()
{} {‘a’: 1} {‘a’: 1} try_convert()
{} {‘a’: 1} {‘a’: 1} force_convert()
{} {‘a’: 1} {‘a’: 1} ¶ Method {}
{"a": 1}
(("a", 1), )
is_type()
True
True
False
validate()
NOP [1] NOP [1] E [2] convert()
{} {‘a’: 1} E [2] try_convert()
{} {‘a’: 1} None
force_convert()
{} {‘a’: 1} {‘a’: 1} strict_level
- Represents how much strict to detect the value type. Higher
strict_level
means that stricter type check.
-
convert
()¶ Returns: Converted value. Raises: typepy.TypeConversionError – If the value cannot convert.
-
force_convert
()¶ Returns: Converted value. Raises: typepy.TypeConversionError – If the value cannot convert.
7.2.4. Infinity Type¶
-
class
typepy.
Infinity
(value: Any, strict_level: int = 1, **kwargs)[source]¶ For each member methods, the result matrix for each
strict_level
is as follows. Column headers (exceptMethod
column) indicate input data tovalue
argument of a method in theMethod
column. For each cell shows the output of the method.¶ Method float("inf")
"Infinity"
0.1
is_type()
True
True
False
validate()
NOP [1] NOP [1] E [2] convert()
Decimal("inf")
Decimal("inf")
E [2] try_convert()
Decimal("inf")
Decimal("inf")
None
force_convert()
Decimal("inf")
Decimal("inf")
0.1 ¶ Method float("inf")
"Infinity"
0.1
is_type()
True
False
False
validate()
NOP [1] E [2] E [2] convert()
Decimal("inf")
E [2] E [2] try_convert()
Decimal("inf")
None
None
force_convert()
Decimal("inf")
Decimal("inf")
0.1 strict_level
- Represents how much strict to detect the value type. Higher
strict_level
means that stricter type check.
-
convert
()¶ Returns: Converted value. Raises: typepy.TypeConversionError – If the value cannot convert.
-
force_convert
()¶ Returns: Converted value. Raises: typepy.TypeConversionError – If the value cannot convert.
7.2.5. Integer Type¶
-
class
typepy.
Integer
(value: Any, strict_level: int = 1, **kwargs)[source]¶ For each member methods, the result matrix for each
strict_level
is as follows. Column headers (exceptMethod
column) indicate input data tovalue
argument of a method in theMethod
column. For each cell shows the output of the method.¶ Method 1
1.0
1.1
"1"
"1.0"
"1.1"
True
is_type()
True
True
True
True
True
True
True
validate()
NOP [1] NOP [1] NOP [1] NOP [1] NOP [1] NOP [1] NOP [1] convert()
1 1 1 1 1 1 1 try_convert()
1 1 1 1 1 1 1 force_convert()
1 1 1 1 1 1 1 ¶ Method 1
1.0
1.1
"1"
"1.0"
"1.1"
True
is_type()
True
True
False
True
True
False
False
validate()
NOP [1] NOP [1] E [2] NOP [1] NOP [1] E [2] E [2] convert()
1 1 E [2] 1 1 E [2] E [2] try_convert()
1 1 None
1 1 None
None
force_convert()
1 1 1 1 1 1 1 ¶ Method 1
1.0
1.1
"1"
"1.0"
"1.1"
True
is_type()
True
False
False
False
False
False
False
validate()
NOP [1] E [2] E [2] E [2] E [2] E [2] E [2] convert()
1 E [2] E [2] E [2] E [2] E [2] E [2] try_convert()
1 None
None
None
None
None
None
force_convert()
1 1 1 1 1 1 1 strict_level
- Represents how much strict to detect the value type. Higher
strict_level
means that stricter type check.
-
convert
()¶ Returns: Converted value. Raises: typepy.TypeConversionError – If the value cannot convert.
-
force_convert
()¶ Returns: Converted value. Raises: typepy.TypeConversionError – If the value cannot convert.
7.2.6. IP address Type¶
-
class
typepy.
IpAddress
(value: Any, strict_level: int = 1, **kwargs)[source]¶ For each member methods, the result matrix for each
strict_level
is as follows. Column headers (exceptMethod
column) indicate input data tovalue
argument of a method in theMethod
column. For each cell shows the output of the method.¶ Method ip_address('127.0.0.1')
'127.0.0.1'
'::1'
'192.168.0.256'
None
is_type()
True
True
True
False
False
validate()
NOP [1] NOP [1] NOP [1] E [2] E [2] convert()
ip_address("127.0.0.1")
ip_address("127.0.0.1")
"::1"
E [2] E [2] try_convert()
ip_address("127.0.0.1")
ip_address("127.0.0.1")
"::1"
None
None
force_convert()
ip_address("127.0.0.1")
ip_address("127.0.0.1")
"::1"
E [2] E [2] ¶ Method ip_address('127.0.0.1')
'127.0.0.1'
'::1'
'192.168.0.256'
None
is_type()
True
False
False
False
False
validate()
NOP [1] E [2] E [2] E [2] E [2] convert()
ip_address("127.0.0.1")
E [2] E [2] E [2] E [2] try_convert()
ip_address("127.0.0.1")
None
None
None
None
force_convert()
ip_address("127.0.0.1")
ip_address("127.0.0.1")
"::1"
E [2] E [2] strict_level
- Represents how much strict to detect the value type. Higher
strict_level
means that stricter type check.
-
convert
()¶ Returns: Converted value. Raises: typepy.TypeConversionError – If the value cannot convert.
-
force_convert
()¶ Returns: Converted value. Raises: typepy.TypeConversionError – If the value cannot convert.
7.2.7. List Type¶
-
class
typepy.
List
(value: Any, strict_level: int = 1, **kwargs)[source]¶ For each member methods, the result matrix for each
strict_level
is as follows. Column headers (exceptMethod
column) indicate input data tovalue
argument of a method in theMethod
column. For each cell shows the output of the method.¶ Method []
["a", "b"]
("a", "b")
{"a": 1}
"abc"
is_type()
True
True
True
True
False
validate()
NOP [1] NOP [1] NOP [1] NOP [1] E [2] convert()
[] [‘a’, ‘b’] [‘a’, ‘b’] [‘a’] E [2] try_convert()
[] [‘a’, ‘b’] [‘a’, ‘b’] [‘a’] None
force_convert()
[] [‘a’, ‘b’] [‘a’, ‘b’] [‘a’] [‘a’, ‘b’, ‘c’] ¶ Method []
["a", "b"]
("a", "b")
{"a": 1}
"abc"
is_type()
True
True
False
False
False
validate()
NOP [1] NOP [1] E [2] E [2] E [2] convert()
[] [‘a’, ‘b’] E [2] E [2] E [2] try_convert()
[] [‘a’, ‘b’] None
None
None
force_convert()
[] [‘a’, ‘b’] [‘a’, ‘b’] [‘a’] [‘a’, ‘b’, ‘c’] strict_level
- Represents how much strict to detect the value type. Higher
strict_level
means that stricter type check.
-
convert
()¶ Returns: Converted value. Raises: typepy.TypeConversionError – If the value cannot convert.
-
force_convert
()¶ Returns: Converted value. Raises: typepy.TypeConversionError – If the value cannot convert.
7.2.8. NaN Type¶
-
class
typepy.
Nan
(value: Any, strict_level: int = 1, **kwargs)[source]¶ For each member methods, the result matrix for each
strict_level
is as follows. Column headers (exceptMethod
column) indicate input data tovalue
argument of a method in theMethod
column. For each cell shows the output of the method.¶ Method float("nan")
"NaN"
0.1
is_type()
True
True
False
validate()
NOP [1] NOP [1] E [2] convert()
Decimal("nan")
Decimal("nan")
E [2] try_convert()
Decimal("nan")
Decimal("nan")
None
force_convert()
Decimal("nan")
Decimal("nan")
0.1 ¶ Method float("nan")
"NaN"
0.1
is_type()
True
False
False
validate()
NOP [1] E [2] E [2] convert()
Decimal("nan")
E [2] E [2] try_convert()
Decimal("nan")
None
None
force_convert()
Decimal("nan")
Decimal("nan")
0.1 strict_level
- Represents how much strict to detect the value type. Higher
strict_level
means that stricter type check.
-
convert
()¶ Returns: Converted value. Raises: typepy.TypeConversionError – If the value cannot convert.
-
force_convert
()¶ Returns: Converted value. Raises: typepy.TypeConversionError – If the value cannot convert.
7.2.9. None Type¶
-
class
typepy.
NoneType
(value: Any, strict_level: int = 0, **kwargs)[source]¶ For each member methods, the result matrix for each
strict_level
is as follows. Column headers (exceptMethod
column) indicate input data tovalue
argument of a method in theMethod
column. For each cell shows the output of the method.¶ Method "abc"
""
" "
None
1
is_type()
False
False
False
True
False
validate()
E [2] E [2] E [2] NOP [1] E [2] convert()
E [2] E [2] E [2] None
E [2] try_convert()
None
None
None
None
None
force_convert()
None
None
None
None
None
strict_level
- Represents how much strict to detect the value type. Higher
strict_level
means that stricter type check.
-
convert
()¶ Returns: Converted value. Raises: typepy.TypeConversionError – If the value cannot convert.
-
force_convert
()[source]¶ Returns: Converted value. Raises: typepy.TypeConversionError – If the value cannot convert.
7.2.10. Null String Type¶
-
class
typepy.
NullString
(value: Any, strict_level: int = 1, **kwargs)[source]¶ For each member methods, the result matrix for each
strict_level
is as follows. Column headers (exceptMethod
column) indicate input data tovalue
argument of a method in theMethod
column. For each cell shows the output of the method.¶ Method "abc"
""
" "
None
1
is_type()
False
True
True
True
False
validate()
E [2] NOP [1] NOP [1] NOP [1] E [2] convert()
E [2] ""
""
""
E [2] try_convert()
None
""
""
""
None
force_convert()
""
""
""
""
""
¶ Method "abc"
""
" "
None
1
is_type()
False
True
True
False
False
validate()
E [2] NOP [1] NOP [1] E [2] E [2] convert()
E [2] ""
""
E [2] E [2] try_convert()
None
""
""
None
None
force_convert()
""
""
""
""
""
strict_level
- Represents how much strict to detect the value type. Higher
strict_level
means that stricter type check.
-
convert
()¶ Returns: Converted value. Raises: typepy.TypeConversionError – If the value cannot convert.
-
force_convert
()¶ Returns: Converted value. Raises: typepy.TypeConversionError – If the value cannot convert.
7.2.11. Real Number Type¶
-
class
typepy.
RealNumber
(value: Any, strict_level: int = 0, **kwargs)[source]¶ For each member methods, the result matrix for each
strict_level
is as follows. Column headers (exceptMethod
column) indicate input data tovalue
argument of a method in theMethod
column. For each cell shows the output of the method.¶ Method 1
1.0
1.1
"1"
"1.0"
"1.1"
True
is_type()
True
True
True
True
True
True
False
validate()
NOP [1] NOP [1] NOP [1] NOP [1] NOP [1] NOP [1] E [2] convert()
1 1 1.1 1 1 1.1 E [2] try_convert()
1 1 1.1 1 1 1.1 None
force_convert()
1 1 1.1 1 1 1.1 1 ¶ Method 1
1.0
1.1
"1"
"1.0"
"1.1"
True
is_type()
False
False
True
False
False
True
False
validate()
E [2] E [2] NOP [1] E [2] E [2] NOP [1] E [2] convert()
E [2] E [2] 1.1 E [2] E [2] 1.1 E [2] try_convert()
None
None
1.1 None
None
1.1 None
force_convert()
1 1 1.1 1 1 1.1 1 ¶ Method 1
1.0
1.1
"1"
"1.0"
"1.1"
True
is_type()
False
False
True
False
False
False
False
validate()
E [2] E [2] NOP [1] E [2] E [2] E [2] E [2] convert()
E [2] E [2] 1.1 E [2] E [2] E [2] E [2] try_convert()
None
None
1.1 None
None
None
None
force_convert()
1 1 1.1 1 1 1.1 1 strict_level
- Represents how much strict to detect the value type. Higher
strict_level
means that stricter type check.
-
convert
()¶ Returns: Converted value. Raises: typepy.TypeConversionError – If the value cannot convert.
-
force_convert
()¶ Returns: Converted value. Raises: typepy.TypeConversionError – If the value cannot convert.
7.2.12. String Type¶
-
class
typepy.
String
(value: Any, strict_level: int = 1, **kwargs)[source]¶ For each member methods, the result matrix for each
strict_level
is as follows. Column headers (exceptMethod
column) indicate input data tovalue
argument of a method in theMethod
column. For each cell shows the output of the method.¶ Method "abc"
""
" "
None
1
is_type()
True
True
True
True
True
validate()
NOP [1] NOP [1] NOP [1] NOP [1] NOP [1] convert()
"abc"
""
" "
"None"
"1"
try_convert()
"abc"
""
" "
"None"
"1"
force_convert()
"abc"
""
" "
"None"
"1"
¶ Method "abc"
""
" "
None
1
is_type()
True
True
True
False
False
validate()
NOP [1] NOP [1] NOP [1] E [2] E [2] convert()
"abc"
""
" "
E [2] E [2] try_convert()
"abc"
""
" "
None
None
force_convert()
"abc"
""
" "
"None"
"1"
¶ Method "abc"
""
" "
None
1
is_type()
True
False
False
False
False
validate()
NOP [1] E [2] E [2] E [2] E [2] convert()
"abc"
E [2] E [2] E [2] E [2] try_convert()
"abc"
None
None
None
None
force_convert()
"abc"
""
" "
"None"
"1"
strict_level
- Represents how much strict to detect the value type. Higher
strict_level
means that stricter type check.
-
convert
()¶ Returns: Converted value. Raises: typepy.TypeConversionError – If the value cannot convert.
-
force_convert
()¶ Returns: Converted value. Raises: typepy.TypeConversionError – If the value cannot convert.
[1] | (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 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, 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) No Operation |
[2] | (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 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, 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, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126) Error (raise TypeError ) |
[3] | Error (raise typepy.TypeConversionError ) |