diff --git a/src/adaptix/_internal/morphing/json_schema/infrastructure_provider.py b/src/adaptix/_internal/morphing/json_schema/providers.py similarity index 100% rename from src/adaptix/_internal/morphing/json_schema/infrastructure_provider.py rename to src/adaptix/_internal/morphing/json_schema/providers.py diff --git a/src/adaptix/_internal/morphing/model/dumper_gen.py b/src/adaptix/_internal/morphing/model/dumper_gen.py index 7b53b5bb..a58c2632 100644 --- a/src/adaptix/_internal/morphing/model/dumper_gen.py +++ b/src/adaptix/_internal/morphing/model/dumper_gen.py @@ -1,7 +1,7 @@ import contextlib from dataclasses import replace from string import Template -from typing import Any, Callable, Dict, Mapping, NamedTuple, Optional, Tuple +from typing import Any, Callable, Dict, Mapping, NamedTuple, Tuple from ...code_tools.cascade_namespace import BuiltinCascadeNamespace, CascadeNamespace from ...code_tools.code_builder import CodeBuilder @@ -679,17 +679,13 @@ def _convert_dict_crown(self, crown: OutDictCrown) -> JSONSchema: if self._is_required_crown(value) ], properties={ - key: value - for key, value in ( - (key, self.convert_crown(value)) - for key, value in crown.map.items() - ) - if value is not None + key: self.convert_crown(value) + for key, value in crown.map.items() }, additional_properties=self._extra_move is not None, ) - def _convert_list_crown(self, crown: OutListCrown) -> Optional[JSONSchema]: + def _convert_list_crown(self, crown: OutListCrown) -> JSONSchema: items = [ self.convert_crown(sub_crown) for sub_crown in crown.map @@ -701,27 +697,27 @@ def _convert_list_crown(self, crown: OutListCrown) -> Optional[JSONSchema]: min_items=len(items), ) - def _convert_field_crown(self, crown: OutFieldCrown) -> Optional[JSONSchema]: + def _convert_field_crown(self, crown: OutFieldCrown) -> JSONSchema: field = self._shape.fields_dict[crown.id] json_schema = self._field_json_schema_getter(field) if field.default == NoDefault(): return json_schema return replace(json_schema, default=self._field_default_dumper(field)) - def _convert_none_crown(self, crown: OutNoneCrown) -> Optional[JSONSchema]: + def _convert_none_crown(self, crown: OutNoneCrown) -> JSONSchema: value = ( crown.placeholder.factory() if isinstance(crown.placeholder, DefaultFactory) else crown.placeholder.value ) - return self._placeholder_dumper(value) + return JSONSchema(const=self._placeholder_dumper(value)) def _is_required_crown(self, crown: OutCrown) -> bool: if isinstance(crown, OutFieldCrown): return self._shape.fields_dict[crown.id].is_required return True - def convert_crown(self, crown: OutCrown) -> Optional[JSONSchema]: + def convert_crown(self, crown: OutCrown) -> JSONSchema: if isinstance(crown, OutDictCrown): return self._convert_dict_crown(crown) if isinstance(crown, OutListCrown): diff --git a/src/adaptix/_internal/morphing/model/loader_gen.py b/src/adaptix/_internal/morphing/model/loader_gen.py index f687ee71..23af85cb 100644 --- a/src/adaptix/_internal/morphing/model/loader_gen.py +++ b/src/adaptix/_internal/morphing/model/loader_gen.py @@ -804,17 +804,13 @@ def _convert_dict_crown(self, crown: InpDictCrown) -> JSONSchema: if self._is_required_crown(value) ], properties={ - key: value - for key, value in ( - (key, self.convert_crown(value)) - for key, value in crown.map.items() - ) - if value is not None + key: self.convert_crown(value) + for key, value in crown.map.items() }, additional_properties=crown.extra_policy != ExtraForbid(), ) - def _convert_list_crown(self, crown: InpListCrown) -> Optional[JSONSchema]: + def _convert_list_crown(self, crown: InpListCrown) -> JSONSchema: items = [ self.convert_crown(sub_crown) for sub_crown in crown.map @@ -826,15 +822,15 @@ def _convert_list_crown(self, crown: InpListCrown) -> Optional[JSONSchema]: min_items=len(items), ) - def _convert_field_crown(self, crown: InpFieldCrown) -> Optional[JSONSchema]: + def _convert_field_crown(self, crown: InpFieldCrown) -> JSONSchema: field = self._shape.fields_dict[crown.id] json_schema = self._field_json_schema_getter(field) if field.default == NoDefault(): return json_schema return replace(json_schema, default=self._field_default_dumper(field)) - def _convert_none_crown(self, crown: InpNoneCrown) -> Optional[JSONSchema]: - return None + def _convert_none_crown(self, crown: InpNoneCrown) -> JSONSchema: + return JSONSchema() def _is_required_crown(self, crown: InpCrown) -> bool: if isinstance(crown, InpFieldCrown): @@ -843,7 +839,7 @@ def _is_required_crown(self, crown: InpCrown) -> bool: return False return True - def convert_crown(self, crown: InpCrown) -> Optional[JSONSchema]: + def convert_crown(self, crown: InpCrown) -> JSONSchema: if isinstance(crown, InpDictCrown): return self._convert_dict_crown(crown) if isinstance(crown, InpListCrown): diff --git a/src/adaptix/_internal/morphing/name_layout/component.py b/src/adaptix/_internal/morphing/name_layout/component.py index c3f32279..068c47c0 100644 --- a/src/adaptix/_internal/morphing/name_layout/component.py +++ b/src/adaptix/_internal/morphing/name_layout/component.py @@ -2,8 +2,6 @@ from dataclasses import dataclass from typing import Callable, DefaultDict, Dict, Iterable, List, Mapping, Optional, Sequence, Set, Tuple, TypeVar, Union -from adaptix import ProviderNotFoundError - from ...common import VarTuple from ...model_tools.definitions import ( BaseField, @@ -22,6 +20,7 @@ from ...provider.located_request import LocatedRequest from ...provider.overlay_schema import Overlay, Schema, provide_schema from ...retort.operating_retort import OperatingRetort +from ...retort.searching_retort import ProviderNotFoundError from ...special_cases_optimization import with_default_clause from ...utils import Omittable, get_prefix_groups from ..model.crown_definitions import ( diff --git a/tests/unit/morphing/facade/test_retort.py b/tests/unit/morphing/facade/test_retort.py index 0c3a0f76..0ad61d4b 100644 --- a/tests/unit/morphing/facade/test_retort.py +++ b/tests/unit/morphing/facade/test_retort.py @@ -27,7 +27,7 @@ def test_retort_extend(): extended_retort = retort.extend(recipe=to_extend) assert retort._get_full_recipe() == recipe_before_extend - assert extended_retort._get_full_recipe()[:len(to_extend)] == to_extend + assert extended_retort._get_full_recipe()[1:len(to_extend)+1] == to_extend assert not extended_retort._loader_cache assert not extended_retort._dumper_cache