Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions docs/source/utilities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ Utilities for Data Items

.. autofunction:: balderhub.data.lib.utils.functions.full_dictionary_is_not_definable


Additional / Special Types
==========================

.. autoclass:: balderhub.data.lib.utils.UnorderedList

Response Messages
=================

Expand Down
4 changes: 1 addition & 3 deletions src/balderhub/data/lib/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from .response_message_list import ResponseMessageList
from .single_data_item import SingleDataItem
from .single_data_item_collection import SingleDataItemCollection
from .unordered_list import UnorderedList

__all__ = [
'NOT_DEFINABLE',
Expand All @@ -15,6 +14,5 @@
'ResponseMessage',
'ResponseMessageList',
'SingleDataItem',
'SingleDataItemCollection',
'UnorderedList'
'SingleDataItemCollection'
]
21 changes: 3 additions & 18 deletions src/balderhub/data/lib/utils/single_data_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from .functions import convert_field_lookups_to_dict_structure
from .lookup_field_string import LookupFieldString
from .not_definable import NOT_DEFINABLE
from .unordered_list import UnorderedList

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -73,7 +72,7 @@ def _validate_element(mcs, type_def, allow_nesting=True):
if not allow_nesting:
raise MisconfiguredDataItemError('nesting typing is only allowed for list')
# references another type definition
if get_origin(type_def) in [list, List, UnorderedList]:
if get_origin(type_def) in [list, List]:
inner_args = get_args(type_def)
if len(inner_args) != 1:
raise MisconfiguredDataItemError('list type definition can only have one argument for '
Expand Down Expand Up @@ -205,7 +204,7 @@ def get_element_type_for_list(cls, field_lookup: str | LookupFieldString) -> typ
"""
cleaned_type = cls.get_cleaned_field_data_type(field_lookup)

if cls.get_field_data_type(field_lookup) not in [list, UnorderedList]:
if cls.get_field_data_type(field_lookup) != list:
raise TypeError(f'the referenced field `{field_lookup}` is no list (is from type `{cleaned_type}`)')
if cls.is_optional_field(field_lookup):
inner_args = set(get_args(cleaned_type))
Expand Down Expand Up @@ -361,9 +360,6 @@ def get_data_type(_of_element_type) -> type:
if get_origin(_of_element_type) in [list, List]:
return list

if get_origin(_of_element_type) in [UnorderedList]:
return UnorderedList

if get_origin(_of_element_type) is Optional:
return get_data_type(get_args(_of_element_type)[0])

Expand Down Expand Up @@ -595,7 +591,7 @@ def needs_to_be_checked(self_val, other_val):
f"set - self={self_value} | other={other_value}")
continue

if field_data_type in [list, UnorderedList]:
if field_data_type is list:
if allow_non_definable and self_value == NOT_DEFINABLE or other_value == NOT_DEFINABLE:
# ignore
continue
Expand All @@ -607,17 +603,6 @@ def needs_to_be_checked(self_val, other_val):
f"self={len(self_value)}, other={len(other_value)}")
else:
idx = 0

# TODO improve this implementation
if field_data_type is UnorderedList:

sorted_kwargs = {}
if issubclass(inner_type, SingleDataItem):
sorted_kwargs['key'] = lambda x: x.get_unique_identification()

self_value = sorted(self_value, **sorted_kwargs)
other_value = sorted(other_value, **sorted_kwargs)

# both lists have the same length -> start comparing items
for cur_self_item, cur_other_item in zip(self_value, other_value):
if not needs_to_be_checked(cur_self_item, cur_other_item):
Expand Down
43 changes: 0 additions & 43 deletions src/balderhub/data/lib/utils/unordered_list.py

This file was deleted.

124 changes: 0 additions & 124 deletions tests/scenarios/scenario_utils_single_data_item_unordered_list.py

This file was deleted.

80 changes: 0 additions & 80 deletions tests/scenarios/scenario_utils_unordered_list.py

This file was deleted.

Loading