我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用graphene.Float()。
def get_field_args(field): types = { str: graphene.String, bool: graphene.Boolean, int: graphene.Int, float: graphene.Float, } try: args = inspect.signature(field) result = {} for name, arg in args.parameters.items(): if arg.default is not None: custom_type = types[type(arg.default)] else: custom_type = graphene.String result.update({name: custom_type()}) return result except (KeyError, ValueError): return {}
def convert_form_field_to_float(field): return Float(description=field.help_text, required=field.required)
def test_should_auto_convert_duration(): assert_conversion(models.DurationField, graphene.Float)
def test_should_float_convert_float(): assert_conversion(models.FloatField, graphene.Float)
def test_should_float_convert_float(): assert_conversion(forms.FloatField, graphene.Float)
def test_should_decimal_convert_float(): assert_conversion(forms.DecimalField, graphene.Float)
def test_should_decimal_convert_float(): assert_conversion(serializers.DecimalField, graphene.Float, max_digits=4, decimal_places=2)
def convert_ndb_float_property(ndb_prop, registry=None): return convert_ndb_scalar_property(Float, ndb_prop)
def testFloatProperty_shouldConvertToString(self): self.__assert_conversion(ndb.FloatProperty, graphene.Float)
def ASNFieldConvert(field, registry=None): return graphene.Float() # Nodes