| Total Complexity | 2 |
| Total Lines | 23 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | from datetime import datetime |
||
| 2 | from typing import Optional |
||
| 3 | from jsons.exceptions import DeserializationError |
||
| 4 | from jsons._main_impl import load |
||
| 5 | |||
| 6 | |||
| 7 | def default_string_deserializer(obj: str, |
||
| 8 | cls: Optional[type] = None, |
||
| 9 | **kwargs) -> object: |
||
| 10 | """ |
||
| 11 | Deserialize a string. If the given ``obj`` can be parsed to a date, a |
||
| 12 | ``datetime`` instance is returned. |
||
| 13 | :param obj: the string that is to be deserialized. |
||
| 14 | :param cls: not used. |
||
| 15 | :param kwargs: any keyword arguments. |
||
| 16 | :return: the deserialized obj. |
||
| 17 | """ |
||
| 18 | try: |
||
| 19 | result = load(obj, datetime, **kwargs) |
||
| 20 | except DeserializationError: |
||
| 21 | result = obj |
||
| 22 | return result |
||
| 23 |