Skip to content

Commit 3f3593e

Browse files
committed
better naming conventions (suggested by @erikwrede)
1 parent 6f6c61c commit 3f3593e

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

graphene_sqlalchemy/converter.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def convert_json_type_to_string(type, column, registry=None):
270270

271271

272272
@singledispatchbymatchfunction
273-
def convert_hybrid_property_return_type_inner(arg: Any):
273+
def convert_sqlalchemy_hybrid_property_type(arg: Any):
274274
existing_graphql_type = get_global_registry().get_type_for_model(arg)
275275
if existing_graphql_type:
276276
return existing_graphql_type
@@ -283,60 +283,60 @@ def convert_hybrid_property_return_type_inner(arg: Any):
283283
return String
284284

285285

286-
@convert_hybrid_property_return_type_inner.register(value_equals(str))
287-
def convert_hybrid_property_return_type_inner_str(arg):
286+
@convert_sqlalchemy_hybrid_property_type.register(value_equals(str))
287+
def convert_sqlalchemy_hybrid_property_type_str(arg):
288288
return String
289289

290290

291-
@convert_hybrid_property_return_type_inner.register(value_equals(int))
292-
def convert_hybrid_property_return_type_inner_int(arg):
291+
@convert_sqlalchemy_hybrid_property_type.register(value_equals(int))
292+
def convert_sqlalchemy_hybrid_property_type_int(arg):
293293
return Int
294294

295295

296-
@convert_hybrid_property_return_type_inner.register(value_equals(float))
297-
def convert_hybrid_property_return_type_inner_float(arg):
296+
@convert_sqlalchemy_hybrid_property_type.register(value_equals(float))
297+
def convert_sqlalchemy_hybrid_property_type_float(arg):
298298
return Float
299299

300300

301-
@convert_hybrid_property_return_type_inner.register(value_equals(Decimal))
302-
def convert_hybrid_property_return_type_inner_decimal(arg):
301+
@convert_sqlalchemy_hybrid_property_type.register(value_equals(Decimal))
302+
def convert_sqlalchemy_hybrid_property_type_decimal(arg):
303303
# The reason Decimal should be serialized as a String is because this is a
304304
# base10 type used in things like money, and string allows it to not
305305
# lose precision (which would happen if we downcasted to a Float, for example)
306306
return String
307307

308308

309-
@convert_hybrid_property_return_type_inner.register(value_equals(bool))
310-
def convert_hybrid_property_return_type_inner_bool(arg):
309+
@convert_sqlalchemy_hybrid_property_type.register(value_equals(bool))
310+
def convert_sqlalchemy_hybrid_property_type_bool(arg):
311311
return Boolean
312312

313313

314-
@convert_hybrid_property_return_type_inner.register(value_equals(datetime.datetime))
315-
def convert_hybrid_property_return_type_inner_datetime(arg):
314+
@convert_sqlalchemy_hybrid_property_type.register(value_equals(datetime.datetime))
315+
def convert_sqlalchemy_hybrid_property_type_datetime(arg):
316316
return DateTime
317317

318318

319-
@convert_hybrid_property_return_type_inner.register(value_equals(datetime.date))
320-
def convert_hybrid_property_return_type_inner_date(arg):
319+
@convert_sqlalchemy_hybrid_property_type.register(value_equals(datetime.date))
320+
def convert_sqlalchemy_hybrid_property_type_date(arg):
321321
return Date
322322

323323

324-
@convert_hybrid_property_return_type_inner.register(value_equals(datetime.time))
325-
def convert_hybrid_property_return_type_inner_time(arg):
324+
@convert_sqlalchemy_hybrid_property_type.register(value_equals(datetime.time))
325+
def convert_sqlalchemy_hybrid_property_type_time(arg):
326326
return Time
327327

328328

329-
@convert_hybrid_property_return_type_inner.register(value_is_subclass(enum.Enum))
330-
def convert_hybrid_property_return_type_inner_enum(arg):
329+
@convert_sqlalchemy_hybrid_property_type.register(value_is_subclass(enum.Enum))
330+
def convert_sqlalchemy_hybrid_property_type_enum(arg):
331331
return Enum.from_enum(arg)
332332

333333

334-
@convert_hybrid_property_return_type_inner.register(lambda x: getattr(x, '__origin__', None) in [list, typing.List])
335-
def convert_hybrid_property_return_type_inner_list(arg):
334+
@convert_sqlalchemy_hybrid_property_type.register(lambda x: getattr(x, '__origin__', None) in [list, typing.List])
335+
def convert_sqlalchemy_hybrid_property_type_list_t(arg):
336336
# type is either list[T] or List[T], generic argument at __args__[0]
337337
internal_type = arg.__args__[0]
338338

339-
graphql_internal_type = convert_hybrid_property_return_type_inner(internal_type)
339+
graphql_internal_type = convert_sqlalchemy_hybrid_property_type(internal_type)
340340

341341
return List(graphql_internal_type)
342342

@@ -345,4 +345,4 @@ def convert_hybrid_property_return_type(hybrid_prop):
345345
# Grab the original method's return type annotations from inside the hybrid property
346346
return_type_annotation = hybrid_prop.fget.__annotations__.get('return', str)
347347

348-
return convert_hybrid_property_return_type_inner(return_type_annotation)
348+
return convert_sqlalchemy_hybrid_property_type(return_type_annotation)

0 commit comments

Comments
 (0)