MCPcopy
hub / github.com/pydantic/pydantic / float_schema

Method float_schema

pydantic/json_schema.py:674–686  ·  view source on GitHub ↗

Generates a JSON schema that matches a float value. Args: schema: The core schema. Returns: The generated JSON schema.

(self, schema: core_schema.FloatSchema)

Source from the content-addressed store, hash-verified

672 return json_schema
673
674 def float_schema(self, schema: core_schema.FloatSchema) -> JsonSchemaValue:
675 """Generates a JSON schema that matches a float value.
676
677 Args:
678 schema: The core schema.
679
680 Returns:
681 The generated JSON schema.
682 """
683 json_schema: dict[str, Any] = {'type': 'number'}
684 self.update_with_validations(json_schema, schema, self.ValidationsMapping.numeric)
685 json_schema = {k: v for k, v in json_schema.items() if v not in {math.inf, -math.inf}}
686 return json_schema
687
688 def decimal_schema(self, schema: core_schema.DecimalSchema) -> JsonSchemaValue:
689 """Generates a JSON schema that matches a decimal value.

Callers 15

decimal_schemaMethod · 0.95
match_typeMethod · 0.80
test_floatFunction · 0.80
test_inf_nan_allowFunction · 0.80
test_dict_keysFunction · 0.80
test_int_to_floatFunction · 0.80
test_int_to_float_keyFunction · 0.80
test_numpyFunction · 0.80
test_property_setterFunction · 0.80

Calls 2

itemsMethod · 0.45

Tested by 15

test_floatFunction · 0.64
test_inf_nan_allowFunction · 0.64
test_dict_keysFunction · 0.64
test_int_to_floatFunction · 0.64
test_int_to_float_keyFunction · 0.64
test_numpyFunction · 0.64
test_property_setterFunction · 0.64
model_serializerFunction · 0.64
test_keysFunction · 0.64