Completed
Push — master ( 2237c1...8f3758 )
by Ramon
15s queued 11s
created

jsons.deserializers.default_decimal   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 7
dl 0
loc 17
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A default_decimal_deserializer() 0 12 1
1
from typing import Optional, Union
2
from decimal import Decimal
3
4
5
def default_decimal_deserializer(obj: Union[str, float, int],
6
                                 cls: Optional[type] = None,
7
                                 **kwargs) -> Decimal:
8
    """
9
    Deserialize a Decimal. Expects a string representation of a number, or
10
    the number itself as a float or int.
11
    :param obj: the string float or int that is to be deserialized.
12
    :param cls: not used.
13
    :param kwargs: any keyword arguments.
14
    :return: the deserialized obj.
15
    """
16
    return Decimal(obj)
17