Skip to content

Commit

Permalink
Fix problems introduced while removing six
Browse files Browse the repository at this point in the history
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().
  • Loading branch information
Lorak-mmk authored and fruch committed Jul 31, 2024
1 parent 2467864 commit fab07e1
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cassandra/datastax/graph/graphson.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/advanced/graph/fluent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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). \
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/advanced/graph/fluent/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/advanced/graph/test_graph_datatype.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/advanced/graph/test_graph_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit fab07e1

Please sign in to comment.