Skip to content

Commit a4f1267

Browse files
committed
run poetry run ruff format
1 parent b3b39f8 commit a4f1267

File tree

3 files changed

+126
-133
lines changed

3 files changed

+126
-133
lines changed

airbyte_cdk/sources/declarative/parsers/manifest_normalizer.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,13 @@ def _replace_parent_streams_with_refs(self) -> None:
164164
if not retriever:
165165
continue
166166
partition_router = retriever.get("partition_router")
167-
routers = partition_router if isinstance(partition_router, list) else [partition_router] if partition_router else []
167+
routers = (
168+
partition_router
169+
if isinstance(partition_router, list)
170+
else [partition_router]
171+
if partition_router
172+
else []
173+
)
168174
for router in routers:
169175
if not isinstance(router, dict):
170176
continue
@@ -177,7 +183,11 @@ def _replace_parent_streams_with_refs(self) -> None:
177183
stream_ref = parent_config.get("stream")
178184
# Only replace if it's a dict and matches any stream in the manifest
179185
for other_idx, other_stream in enumerate(stream_copies):
180-
if stream_ref is not None and isinstance(stream_ref, dict) and stream_ref == other_stream:
186+
if (
187+
stream_ref is not None
188+
and isinstance(stream_ref, dict)
189+
and stream_ref == other_stream
190+
):
181191
parent_config["stream"] = {"$ref": f"#/streams/{other_idx}"}
182192
break
183193

@@ -186,17 +196,18 @@ def _clean_dangling_fields(self) -> None:
186196
Clean the manifest by removing unused definitions and schemas.
187197
This method removes any definitions or schemas that are not referenced by any $ref in the manifest.
188198
"""
199+
189200
def find_all_refs(obj: Dict[str, Any], refs: List[str]) -> None:
190201
"""
191202
Recursively find all $ref paths in the object.
192-
203+
193204
Args:
194205
obj: The object to search through
195206
refs: List to store found reference paths
196207
"""
197208
if not isinstance(obj, dict):
198209
return
199-
210+
200211
for key, value in obj.items():
201212
if key == "$ref" and isinstance(value, str):
202213
# Remove the leading #/ from the ref path
@@ -211,7 +222,7 @@ def find_all_refs(obj: Dict[str, Any], refs: List[str]) -> None:
211222
def clean_section(section: Dict[str, Any], section_path: str) -> None:
212223
"""
213224
Clean a section by removing unreferenced fields.
214-
225+
215226
Args:
216227
section: The section to clean
217228
section_path: The path to this section in the manifest

unit_tests/sources/declarative/parsers/conftest.py

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -143,41 +143,31 @@ def manifest_with_multiple_url_base() -> Dict[str, Any]:
143143
"type": "object",
144144
"$schema": "http://json-schema.org/draft-07/schema#",
145145
"additionalProperties": True,
146-
"properties": {
147-
"a": 1
148-
},
146+
"properties": {"a": 1},
149147
},
150148
"B": {
151149
"type": "object",
152150
"$schema": "http://json-schema.org/draft-07/schema#",
153151
"additionalProperties": True,
154-
"properties": {
155-
"b": 2
156-
},
152+
"properties": {"b": 2},
157153
},
158154
"C": {
159155
"type": "object",
160156
"$schema": "http://json-schema.org/draft-07/schema#",
161157
"additionalProperties": True,
162-
"properties": {
163-
"c": 3
164-
},
158+
"properties": {"c": 3},
165159
},
166160
"D": {
167161
"type": "object",
168162
"$schema": "http://json-schema.org/draft-07/schema#",
169163
"additionalProperties": True,
170-
"properties": {
171-
"d": 4
172-
},
164+
"properties": {"d": 4},
173165
},
174166
"E": {
175167
"type": "object",
176168
"$schema": "http://json-schema.org/draft-07/schema#",
177169
"additionalProperties": True,
178-
"properties": {
179-
"e": 5
180-
},
170+
"properties": {"e": 5},
181171
},
182172
},
183173
}
@@ -212,9 +202,7 @@ def expected_manifest_with_multiple_url_base_normalized() -> Dict[str, Any]:
212202
"type": "object",
213203
"$schema": "http://json-schema.org/draft-07/schema#",
214204
"additionalProperties": True,
215-
"properties": {
216-
"a": 1
217-
},
205+
"properties": {"a": 1},
218206
},
219207
},
220208
},
@@ -241,9 +229,7 @@ def expected_manifest_with_multiple_url_base_normalized() -> Dict[str, Any]:
241229
"type": "object",
242230
"$schema": "http://json-schema.org/draft-07/schema#",
243231
"additionalProperties": True,
244-
"properties": {
245-
"b": 2
246-
},
232+
"properties": {"b": 2},
247233
},
248234
},
249235
},
@@ -270,9 +256,7 @@ def expected_manifest_with_multiple_url_base_normalized() -> Dict[str, Any]:
270256
"type": "object",
271257
"$schema": "http://json-schema.org/draft-07/schema#",
272258
"additionalProperties": True,
273-
"properties": {
274-
"c": 3
275-
},
259+
"properties": {"c": 3},
276260
},
277261
},
278262
},
@@ -299,9 +283,7 @@ def expected_manifest_with_multiple_url_base_normalized() -> Dict[str, Any]:
299283
"type": "object",
300284
"$schema": "http://json-schema.org/draft-07/schema#",
301285
"additionalProperties": True,
302-
"properties": {
303-
"d": 4
304-
},
286+
"properties": {"d": 4},
305287
},
306288
},
307289
},
@@ -328,10 +310,8 @@ def expected_manifest_with_multiple_url_base_normalized() -> Dict[str, Any]:
328310
"type": "object",
329311
"$schema": "http://json-schema.org/draft-07/schema#",
330312
"additionalProperties": True,
331-
"properties": {
332-
"e": 5
333-
}
334-
}
313+
"properties": {"e": 5},
314+
},
335315
},
336316
},
337317
],

0 commit comments

Comments
 (0)