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_levelis as follows. Column headers (exceptMethodcolumn) indicate input data tovalueargument of a method in theMethodcolumn. For each cell shows the output of the method.typepy.Bool:strict_level= 0¶Method
True"true"1
is_type()TrueTrueTruevalidate()NOP [1]
NOP [1]
NOP [1]
convert()TrueTrueTruetry_convert()TrueTrueTrueforce_convert()TrueTrueTruetypepy.Bool:strict_level= 1¶Method
True"true"1
is_type()TrueTrueFalsevalidate()NOP [1]
NOP [1]
E [2]
convert()TrueTrueE [2]
try_convert()TrueTrueNoneforce_convert()TrueTrueTruetypepy.Bool:strict_level= 2¶Method
True"true"1
is_type()TrueFalseFalsevalidate()NOP [1]
E [2]
E [2]
convert()TrueE [2]
E [2]
try_convert()TrueNoneNoneforce_convert()TrueTrueTrue- strict_level¶
Represents how much strict to detect the value type. Higher
strict_levelmeans 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_levelis as follows. Column headers (exceptMethodcolumn) indicate input data tovalueargument of a method in theMethodcolumn. For each cell shows the output of the method.typepy.DateTime:strict_level= 0¶Method
datetime(2017, 1, 23, 4, 56)"2017-01-22T04:56:00+0900"1485685623"1485685623"is_type()TrueTrueTrueTruevalidate()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
typepy.DateTime:strict_level= 1¶Method
datetime(2017, 1, 23, 4, 56)"2017-01-22T04:56:00+0900"1485685623"1485685623"is_type()TrueTrueFalseFalsevalidate()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
NoneNoneforce_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
typepy.DateTime:strict_level= 2¶Method
datetime(2017, 1, 23, 4, 56)"2017-01-22T04:56:00+0900"1485685623"1485685623"is_type()TrueFalseFalseFalsevalidate()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
NoneNoneNoneforce_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_levelRepresents how much strict to detect the value type. Higher
strict_levelmeans 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_levelis as follows. Column headers (exceptMethodcolumn) indicate input data tovalueargument of a method in theMethodcolumn. For each cell shows the output of the method.typepy.Dictionary:strict_level= 0¶Method
{}{"a": 1}(("a", 1), )is_type()TrueTrueTruevalidate()NOP [1]
NOP [1]
NOP [1]
convert(){}
{‘a’: 1}
{‘a’: 1}
try_convert(){}
{‘a’: 1}
{‘a’: 1}
force_convert(){}
{‘a’: 1}
{‘a’: 1}
typepy.Dictionary:strict_level= 1¶Method
{}{"a": 1}(("a", 1), )is_type()TrueTrueFalsevalidate()NOP [1]
NOP [1]
E [2]
convert(){}
{‘a’: 1}
E [2]
try_convert(){}
{‘a’: 1}
Noneforce_convert(){}
{‘a’: 1}
{‘a’: 1}
strict_levelRepresents how much strict to detect the value type. Higher
strict_levelmeans 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_levelis as follows. Column headers (exceptMethodcolumn) indicate input data tovalueargument of a method in theMethodcolumn. For each cell shows the output of the method.typepy.Infinity:strict_level= 0¶Method
float("inf")"Infinity"0.1is_type()TrueTrueFalsevalidate()NOP [1]
NOP [1]
E [2]
convert()Decimal("inf")Decimal("inf")E [2]
try_convert()Decimal("inf")Decimal("inf")Noneforce_convert()Decimal("inf")Decimal("inf")0.1
typepy.Infinity:strict_level= 1¶Method
float("inf")"Infinity"0.1is_type()TrueFalseFalsevalidate()NOP [1]
E [2]
E [2]
convert()Decimal("inf")E [2]
E [2]
try_convert()Decimal("inf")NoneNoneforce_convert()Decimal("inf")Decimal("inf")0.1
strict_levelRepresents how much strict to detect the value type. Higher
strict_levelmeans 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_levelis as follows. Column headers (exceptMethodcolumn) indicate input data tovalueargument of a method in theMethodcolumn. For each cell shows the output of the method.typepy.Integer:strict_level= 0¶Method
11.01.1"1""1.0""1.1"Trueis_type()TrueTrueTrueTrueTrueTrueTruevalidate()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
typepy.Integer:strict_level= 1¶Method
11.01.1"1""1.0""1.1"Trueis_type()TrueTrueFalseTrueTrueFalseFalsevalidate()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
None1
1
NoneNoneforce_convert()1
1
1
1
1
1
1
typepy.Integer:strict_level= 2¶Method
11.01.1"1""1.0""1.1"Trueis_type()TrueFalseFalseFalseFalseFalseFalsevalidate()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
NoneNoneNoneNoneNoneNoneforce_convert()1
1
1
1
1
1
1
strict_levelRepresents how much strict to detect the value type. Higher
strict_levelmeans 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_levelis as follows. Column headers (exceptMethodcolumn) indicate input data tovalueargument of a method in theMethodcolumn. For each cell shows the output of the method.typepy.IpAddress:strict_level= 0¶Method
ip_address('127.0.0.1')'127.0.0.1''::1''192.168.0.256'Noneis_type()TrueTrueTrueFalseFalsevalidate()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"NoneNoneforce_convert()ip_address("127.0.0.1")ip_address("127.0.0.1")"::1"E [2]
E [2]
typepy.IpAddress:strict_level= 1¶Method
ip_address('127.0.0.1')'127.0.0.1''::1''192.168.0.256'Noneis_type()TrueFalseFalseFalseFalsevalidate()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")NoneNoneNoneNoneforce_convert()ip_address("127.0.0.1")ip_address("127.0.0.1")"::1"E [2]
E [2]
strict_levelRepresents how much strict to detect the value type. Higher
strict_levelmeans 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_levelis as follows. Column headers (exceptMethodcolumn) indicate input data tovalueargument of a method in theMethodcolumn. For each cell shows the output of the method.typepy.List:strict_level= 0¶Method
[]["a", "b"]("a", "b"){"a": 1}"abc"is_type()TrueTrueTrueTrueFalsevalidate()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’]
Noneforce_convert()[]
[‘a’, ‘b’]
[‘a’, ‘b’]
[‘a’]
[‘a’, ‘b’, ‘c’]
typepy.List:strict_level= 1¶Method
[]["a", "b"]("a", "b"){"a": 1}"abc"is_type()TrueTrueFalseFalseFalsevalidate()NOP [1]
NOP [1]
E [2]
E [2]
E [2]
convert()[]
[‘a’, ‘b’]
E [2]
E [2]
E [2]
try_convert()[]
[‘a’, ‘b’]
NoneNoneNoneforce_convert()[]
[‘a’, ‘b’]
[‘a’, ‘b’]
[‘a’]
[‘a’, ‘b’, ‘c’]
strict_levelRepresents how much strict to detect the value type. Higher
strict_levelmeans 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_levelis as follows. Column headers (exceptMethodcolumn) indicate input data tovalueargument of a method in theMethodcolumn. For each cell shows the output of the method.typepy.Nan:strict_level= 0¶Method
float("nan")"NaN"0.1is_type()TrueTrueFalsevalidate()NOP [1]
NOP [1]
E [2]
convert()Decimal("nan")Decimal("nan")E [2]
try_convert()Decimal("nan")Decimal("nan")Noneforce_convert()Decimal("nan")Decimal("nan")0.1
typepy.Nan:strict_level= 1¶Method
float("nan")"NaN"0.1is_type()TrueFalseFalsevalidate()NOP [1]
E [2]
E [2]
convert()Decimal("nan")E [2]
E [2]
try_convert()Decimal("nan")NoneNoneforce_convert()Decimal("nan")Decimal("nan")0.1
strict_levelRepresents how much strict to detect the value type. Higher
strict_levelmeans 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_levelis as follows. Column headers (exceptMethodcolumn) indicate input data tovalueargument of a method in theMethodcolumn. For each cell shows the output of the method.typepy.NoneType:strict_level= 0¶Method
"abc"""" "None1is_type()FalseFalseFalseTrueFalsevalidate()E [2]
E [2]
E [2]
NOP [1]
E [2]
convert()E [2]
E [2]
E [2]
NoneE [2]
try_convert()NoneNoneNoneNoneNoneforce_convert()NoneNoneNoneNoneNonestrict_levelRepresents how much strict to detect the value type. Higher
strict_levelmeans 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_levelis as follows. Column headers (exceptMethodcolumn) indicate input data tovalueargument of a method in theMethodcolumn. For each cell shows the output of the method.typepy.NullString:strict_level= 0¶Method
"abc"""" "None1is_type()FalseTrueTrueTrueFalsevalidate()E [2]
NOP [1]
NOP [1]
NOP [1]
E [2]
convert()E [2]
""""""E [2]
try_convert()None""""""Noneforce_convert()""""""""""typepy.NullString:strict_level= 1¶Method
"abc"""" "None1is_type()FalseTrueTrueFalseFalsevalidate()E [2]
NOP [1]
NOP [1]
E [2]
E [2]
convert()E [2]
""""E [2]
E [2]
try_convert()None""""NoneNoneforce_convert()""""""""""strict_levelRepresents how much strict to detect the value type. Higher
strict_levelmeans 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_levelis as follows. Column headers (exceptMethodcolumn) indicate input data tovalueargument of a method in theMethodcolumn. For each cell shows the output of the method.typepy.RealNumber:strict_level= 0¶Method
11.01.1"1""1.0""1.1"Trueis_type()TrueTrueTrueTrueTrueTrueFalsevalidate()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
Noneforce_convert()1
1
1.1
1
1
1.1
1
typepy.RealNumber:strict_level= 1¶Method
11.01.1"1""1.0""1.1"Trueis_type()FalseFalseTrueFalseFalseTrueFalsevalidate()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()NoneNone1.1
NoneNone1.1
Noneforce_convert()1
1
1.1
1
1
1.1
1
typepy.RealNumber:strict_level= 2¶Method
11.01.1"1""1.0""1.1"Trueis_type()FalseFalseTrueFalseFalseFalseFalsevalidate()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()NoneNone1.1
NoneNoneNoneNoneforce_convert()1
1
1.1
1
1
1.1
1
strict_levelRepresents how much strict to detect the value type. Higher
strict_levelmeans 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_levelis as follows. Column headers (exceptMethodcolumn) indicate input data tovalueargument of a method in theMethodcolumn. For each cell shows the output of the method.typepy.String:strict_level= 0¶Method
"abc"""" "None1is_type()TrueTrueTrueTrueTruevalidate()NOP [1]
NOP [1]
NOP [1]
NOP [1]
NOP [1]
convert()"abc"""" ""None""1"try_convert()"abc"""" ""None""1"force_convert()"abc"""" ""None""1"typepy.String:strict_level= 1¶Method
"abc"""" "None1is_type()TrueTrueTrueFalseFalsevalidate()NOP [1]
NOP [1]
NOP [1]
E [2]
E [2]
convert()"abc"""" "E [2]
E [2]
try_convert()"abc"""" "NoneNoneforce_convert()"abc"""" ""None""1"typepy.String:strict_level= 2¶Method
"abc"""" "None1is_type()TrueFalseFalseFalseFalsevalidate()NOP [1]
E [2]
E [2]
E [2]
E [2]
convert()"abc"E [2]
E [2]
E [2]
E [2]
try_convert()"abc"NoneNoneNoneNoneforce_convert()"abc"""" ""None""1"strict_levelRepresents how much strict to detect the value type. Higher
strict_levelmeans 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.