Skip to content

Commit

Permalink
yagni: start with list of strings only
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Feb 7, 2025
1 parent f6824d8 commit eb528a6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
12 changes: 3 additions & 9 deletions singer_sdk/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ def __init__( # noqa: PLR0913
nullable: bool | None = None,
title: str | None = None,
deprecated: bool | None = None,
requires_properties: str | list[str] | None = None,
requires_properties: list[str] | None = None,
**kwargs: t.Any,
) -> None:
"""Initialize Property object.
Expand Down Expand Up @@ -870,13 +870,7 @@ def type_dict(self) -> dict: # type: ignore[override]
if not w.optional:
required.append(w.name)
if w.requires_properties:
# Convert single string to list for consistent handling
required_props = (
[w.requires_properties]
if isinstance(w.requires_properties, str)
else w.requires_properties
)
dependent_required[w.name] = required_props
dependent_required[w.name] = w.requires_properties

result: dict[str, t.Any] = {
"type": ["object", "null"] if self.nullable else "object",
Expand Down Expand Up @@ -1131,7 +1125,7 @@ class PropertiesList(ObjectType):
Examples:
>>> schema = PropertiesList(
... # username/password
... Property("username", StringType, requires_properties="password"),
... Property("username", StringType, requires_properties=["password"]),
... Property("password", StringType, secret=True),
... # OAuth
... Property(
Expand Down
2 changes: 1 addition & 1 deletion tests/core/test_jsonschema_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ def test_discriminated_union():
def test_schema_dependencies():
th = ObjectType(
# username/password
Property("username", StringType, requires_properties="password"),
Property("username", StringType, requires_properties=["password"]),
Property("password", StringType, secret=True),
# OAuth
Property(
Expand Down

0 comments on commit eb528a6

Please sign in to comment.