From fab07e13f86b070c1012901b8cf5587ccb9701c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20Bary=C5=82a?= Date: Mon, 16 Oct 2023 21:47:13 +0200 Subject: [PATCH] Fix problems introduced while removing six six.iterkeys() returns an iterator, but Python's dict.keys() does not, so to pass it to iter() it needs to be first passed trough iter(). --- cassandra/datastax/graph/graphson.py | 2 +- tests/integration/advanced/graph/fluent/__init__.py | 4 ++-- tests/integration/advanced/graph/fluent/test_graph.py | 2 +- tests/integration/advanced/graph/test_graph_datatype.py | 4 ++-- tests/integration/advanced/graph/test_graph_query.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cassandra/datastax/graph/graphson.py b/cassandra/datastax/graph/graphson.py index cf3bf9a2c..335c7f782 100644 --- a/cassandra/datastax/graph/graphson.py +++ b/cassandra/datastax/graph/graphson.py @@ -135,7 +135,7 @@ def serialize(cls, value, writer=None): @classmethod def get_specialized_serializer(cls, value): - if type(value) in int and (value > MAX_INT32 or value < MIN_INT32): + if type(value) is int and (value > MAX_INT32 or value < MIN_INT32): return Int64TypeIO return Int32TypeIO diff --git a/tests/integration/advanced/graph/fluent/__init__.py b/tests/integration/advanced/graph/fluent/__init__.py index bde726c29..155de026c 100644 --- a/tests/integration/advanced/graph/fluent/__init__.py +++ b/tests/integration/advanced/graph/fluent/__init__.py @@ -459,7 +459,7 @@ def _write_and_read_data_types(self, schema, graphson, use_schema=True): for data in schema.fixtures.datatypes().values(): typ, value, deserializer = data vertex_label = VertexLabel([typ]) - property_name = next(vertex_label.non_pk_properties.keys()) + property_name = next(iter(vertex_label.non_pk_properties.keys())) if use_schema or schema is CoreGraphSchema: schema.create_vertex_label(self.session, vertex_label, execution_profile=ep) @@ -537,7 +537,7 @@ def __test_udt(self, schema, graphson, address_class, address_with_tags_class, g = self.fetch_traversal_source(graphson) for typ, value in data.values(): vertex_label = VertexLabel([typ]) - property_name = next(vertex_label.non_pk_properties.keys()) + property_name = next(iter(vertex_label.non_pk_properties.keys())) schema.create_vertex_label(self.session, vertex_label, execution_profile=ep) write_traversal = g.addV(str(vertex_label.label)).property('pkid', vertex_label.id). \ diff --git a/tests/integration/advanced/graph/fluent/test_graph.py b/tests/integration/advanced/graph/fluent/test_graph.py index 190292e6f..911e6d5d5 100644 --- a/tests/integration/advanced/graph/fluent/test_graph.py +++ b/tests/integration/advanced/graph/fluent/test_graph.py @@ -121,7 +121,7 @@ def _send_batch_and_read_results(self, schema, graphson, add_all=False, use_sche for data in datatypes.values(): typ, value, deserializer = data vertex_label = VertexLabel([typ]) - property_name = next(vertex_label.non_pk_properties.keys()) + property_name = next(iter(vertex_label.non_pk_properties.keys())) values[property_name] = value if use_schema or schema is CoreGraphSchema: schema.create_vertex_label(self.session, vertex_label, execution_profile=ep) diff --git a/tests/integration/advanced/graph/test_graph_datatype.py b/tests/integration/advanced/graph/test_graph_datatype.py index 1159527a3..8a261c94d 100644 --- a/tests/integration/advanced/graph/test_graph_datatype.py +++ b/tests/integration/advanced/graph/test_graph_datatype.py @@ -87,7 +87,7 @@ def _test_all_datatypes(self, schema, graphson): for data in schema.fixtures.datatypes().values(): typ, value, deserializer = data vertex_label = VertexLabel([typ]) - property_name = next(vertex_label.non_pk_properties.keys()) + property_name = next(iter(vertex_label.non_pk_properties.keys())) schema.create_vertex_label(self.session, vertex_label, execution_profile=ep) vertex = list(schema.add_vertex(self.session, vertex_label, property_name, value, execution_profile=ep))[0] @@ -168,7 +168,7 @@ def __test_udt(self, schema, graphson, address_class, address_with_tags_class, for typ, value in data.values(): vertex_label = VertexLabel([typ]) - property_name = next(vertex_label.non_pk_properties.keys()) + property_name = next(iter(vertex_label.non_pk_properties.keys())) schema.create_vertex_label(self.session, vertex_label, execution_profile=ep) vertex = list(schema.add_vertex(self.session, vertex_label, property_name, value, execution_profile=ep))[0] diff --git a/tests/integration/advanced/graph/test_graph_query.py b/tests/integration/advanced/graph/test_graph_query.py index fe65f616a..0c889938d 100644 --- a/tests/integration/advanced/graph/test_graph_query.py +++ b/tests/integration/advanced/graph/test_graph_query.py @@ -587,7 +587,7 @@ def _test_basic_query_with_type_wrapper(self, schema, graphson): vl = VertexLabel(['tupleOf(Int, Bigint)']) schema.create_vertex_label(self.session, vl, execution_profile=ep) - prop_name = next(vl.non_pk_properties.keys()) + prop_name = next(iter(vl.non_pk_properties.keys())) with self.assertRaises(InvalidRequest): schema.add_vertex(self.session, vl, prop_name, (1, 42), execution_profile=ep)