From 97ba092de37faab0979e6d1b2231ff822c2d761f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 25 Jul 2023 05:14:46 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- singer_sdk/helpers/_flattening.py | 18 +++++++++--------- singer_sdk/typing.py | 2 +- tests/core/test_jsonschema_helpers.py | 2 +- tests/samples/test_tap_sqlite.py | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/singer_sdk/helpers/_flattening.py b/singer_sdk/helpers/_flattening.py index 29ef35cc2..02585dd80 100644 --- a/singer_sdk/helpers/_flattening.py +++ b/singer_sdk/helpers/_flattening.py @@ -252,15 +252,15 @@ def _flatten_schema( # noqa: C901 else: items.append((new_key, v)) elif len(v.values()) > 0: - if list(v.values())[0][0]["type"] == "string": - list(v.values())[0][0]["type"] = ["null", "string"] - items.append((new_key, list(v.values())[0][0])) - elif list(v.values())[0][0]["type"] == "array": - list(v.values())[0][0]["type"] = ["null", "array"] - items.append((new_key, list(v.values())[0][0])) - elif list(v.values())[0][0]["type"] == "object": - list(v.values())[0][0]["type"] = ["null", "object"] - items.append((new_key, list(v.values())[0][0])) + if next(iter(v.values()))[0]["type"] == "string": + next(iter(v.values()))[0]["type"] = ["null", "string"] + items.append((new_key, next(iter(v.values()))[0])) + elif next(iter(v.values()))[0]["type"] == "array": + next(iter(v.values()))[0]["type"] = ["null", "array"] + items.append((new_key, next(iter(v.values()))[0])) + elif next(iter(v.values()))[0]["type"] == "object": + next(iter(v.values()))[0]["type"] = ["null", "object"] + items.append((new_key, next(iter(v.values()))[0])) # Sort and check for duplicates def _key_func(item): diff --git a/singer_sdk/typing.py b/singer_sdk/typing.py index a8f654c90..ff46d297d 100644 --- a/singer_sdk/typing.py +++ b/singer_sdk/typing.py @@ -966,7 +966,7 @@ def _jsonschema_type_check(jsonschema_type: dict, type_check: tuple[str]) -> boo if schema_type in type_check: return True else: - if jsonschema_type.get("type") in type_check: # noqa: PLR5501 + if jsonschema_type.get("type") in type_check: return True if any( diff --git a/tests/core/test_jsonschema_helpers.py b/tests/core/test_jsonschema_helpers.py index 3e4ba6eca..e1369dcba 100644 --- a/tests/core/test_jsonschema_helpers.py +++ b/tests/core/test_jsonschema_helpers.py @@ -490,7 +490,7 @@ def test_property_creation( property_dict = property_obj.to_dict() assert property_dict == expected_jsonschema for check_fn in TYPE_FN_CHECKS: - property_name = list(property_dict.keys())[0] + property_name = next(iter(property_dict.keys())) property_node = property_dict[property_name] if check_fn in type_fn_checks_true: assert ( diff --git a/tests/samples/test_tap_sqlite.py b/tests/samples/test_tap_sqlite.py index bceaa34b1..e2b1940da 100644 --- a/tests/samples/test_tap_sqlite.py +++ b/tests/samples/test_tap_sqlite.py @@ -48,7 +48,7 @@ def test_tap_sqlite_cli(sqlite_sample_db_config: dict[str, t.Any], tmp_path: Pat def test_sql_metadata(sqlite_sample_tap: SQLTap): stream = t.cast(SQLStream, sqlite_sample_tap.streams["main-t1"]) detected_metadata = stream.catalog_entry["metadata"] - detected_root_md = [md for md in detected_metadata if md["breadcrumb"] == []][0] + detected_root_md = next(md for md in detected_metadata if md["breadcrumb"] == []) detected_root_md = detected_root_md["metadata"] translated_metadata = StreamMetadata.from_dict(detected_root_md) assert detected_root_md["schema-name"] == translated_metadata.schema_name