none-shall-parse 0.6.0__py3-none-any.whl → 0.6.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
none_shall_parse/lists.py CHANGED
@@ -29,20 +29,20 @@ def flatten(some_list: Iterable) -> Generator[Any, None, None]:
29
29
  def safe_list_get(lst: List[T], idx: int, default: T = None) -> T:
30
30
  """
31
31
  Retrieve an element from a list by its index or return a default value if the index
32
- is out of range. This function ensures no IndexError is raised during the retrieval
33
- process by providing a fallback value.
32
+ is out of range or the input is not subscriptable. This function ensures safe retrieval
33
+ by providing a fallback value when access fails.
34
34
 
35
- :param lst: The list from which the element is to be retrieved.
35
+ :param lst: The list from which the element is to be retrieved (may be None).
36
36
  :type lst: List[T]
37
37
  :param idx: The index of the element to retrieve from the list.
38
38
  :type idx: int
39
- :param default: The fallback value to be returned if the index is out of range.
39
+ :param default: The fallback value to be returned if retrieval fails.
40
40
  :type default: T
41
41
  :return: The element at the specified index, or the default value
42
- if the index is out of range.
42
+ if the index is out of range or lst is None/not subscriptable.
43
43
  :rtype: T
44
44
  """
45
45
  try:
46
46
  return lst[idx]
47
- except IndexError:
47
+ except (IndexError, TypeError):
48
48
  return default
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: none-shall-parse
3
- Version: 0.6.0
3
+ Version: 0.6.1
4
4
  Summary: Trinity Shared Python utilities.
5
5
  Author: Andries Niemandt, Jan Badenhorst
6
6
  Author-email: Andries Niemandt <andries.niemandt@trintel.co.za>, Jan Badenhorst <jan@trintel.co.za>
@@ -1,10 +1,10 @@
1
1
  none_shall_parse/__init__.py,sha256=ekNMvJaRzR-SOv2bQAOuH86ImPHXGpIj2NbeCO45GOc,3897
2
2
  none_shall_parse/dates.py,sha256=MeBc_Z4rNloTqUkUq9RLfuKg3gkj7SAdlzJM-gHUwL8,27824
3
3
  none_shall_parse/imeis.py,sha256=20pONoUhLKomZxAJegqSSjG72hZjYs60r8IcaRt-15M,6770
4
- none_shall_parse/lists.py,sha256=PKtYD8H1Z7MqbJQ5eFpsK_jgexLwiratMJiYeRMiOwc,1701
4
+ none_shall_parse/lists.py,sha256=DhbiElDBYTVss1ivDytCCwbUKpKpaCIy4orv8KOK-4M,1765
5
5
  none_shall_parse/parse.py,sha256=77bXZAtwFksRwuZ9Ax0lPxEjFpyjkQBqRa5mBc1WkF4,6843
6
6
  none_shall_parse/strings.py,sha256=F7491CJAHJjL7vdEGwoH_4S6PjaovYUS_yzVGJ-bYIE,8463
7
7
  none_shall_parse/types.py,sha256=WAgILMtW2_fm9MBpUuQvq68yXYBNd3rnSoQk70ibOd4,1320
8
- none_shall_parse-0.6.0.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
9
- none_shall_parse-0.6.0.dist-info/METADATA,sha256=xe3e8WZa_AyId0ml5x-O05AaHloy1fkqgYRDLDSGyBQ,1701
10
- none_shall_parse-0.6.0.dist-info/RECORD,,
8
+ none_shall_parse-0.6.1.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
9
+ none_shall_parse-0.6.1.dist-info/METADATA,sha256=avNqaWqN0AIzfbtdHzk5cW4ENNNOsRKb6DPtn-Mc65I,1701
10
+ none_shall_parse-0.6.1.dist-info/RECORD,,