diff --git a/singer_sdk/typing.py b/singer_sdk/typing.py index 1a689b8fc..49baf0912 100644 --- a/singer_sdk/typing.py +++ b/singer_sdk/typing.py @@ -47,7 +47,7 @@ import json import sys -from typing import Any, Generic, Mapping, TypeVar, Union, cast +from typing import Any, Generic, ItemsView, Mapping, TypeVar, Union, cast import sqlalchemy from jsonschema import validators @@ -544,7 +544,7 @@ def __init__( } } """ - self.wrapped: list[Property] = list(properties) + self.wrapped: dict[str, Property] = {prop.name: prop for prop in properties} self.additional_properties = additional_properties self.pattern_properties = pattern_properties @@ -557,7 +557,7 @@ def type_dict(self) -> dict: # type: ignore # OK: @classproperty vs @property """ merged_props = {} required = [] - for w in self.wrapped: + for w in self.wrapped.values(): merged_props.update(w.to_dict()) if not w.optional: required.append(w.name) @@ -604,13 +604,13 @@ def type_dict(self) -> dict: # type: ignore # OK: @classproperty vs @property class PropertiesList(ObjectType): """Properties list. A convenience wrapper around the ObjectType class.""" - def items(self) -> list[tuple[str, Property]]: + def items(self) -> ItemsView[str, Property]: """Get wrapped properties. Returns: List of (name, property) tuples. """ - return [(p.name, p) for p in self.wrapped] + return self.wrapped.items() def append(self, property: Property) -> None: """Append a property to the property list. @@ -618,7 +618,7 @@ def append(self, property: Property) -> None: Args: property: Property to add """ - self.wrapped.append(property) + self.wrapped[property.name] = property def to_jsonschema_type( diff --git a/tests/snapshots/jsonschema/required_duplicates.json b/tests/snapshots/jsonschema/required_duplicates.json index aaa890002..5484f5247 100644 --- a/tests/snapshots/jsonschema/required_duplicates.json +++ b/tests/snapshots/jsonschema/required_duplicates.json @@ -25,7 +25,6 @@ } }, "required": [ - "email", "email", "username" ] diff --git a/tests/snapshots/jsonschema/required_duplicates_additional_properties.json b/tests/snapshots/jsonschema/required_duplicates_additional_properties.json index c433255b1..17a773ded 100644 --- a/tests/snapshots/jsonschema/required_duplicates_additional_properties.json +++ b/tests/snapshots/jsonschema/required_duplicates_additional_properties.json @@ -25,7 +25,6 @@ } }, "required": [ - "email", "email", "username" ], diff --git a/tests/snapshots/jsonschema/required_duplicates_no_additional_properties.json b/tests/snapshots/jsonschema/required_duplicates_no_additional_properties.json index fd65061f8..dcd44ca07 100644 --- a/tests/snapshots/jsonschema/required_duplicates_no_additional_properties.json +++ b/tests/snapshots/jsonschema/required_duplicates_no_additional_properties.json @@ -25,7 +25,6 @@ } }, "required": [ - "email", "email", "username" ],