MCPcopy
hub / github.com/pydantic/pydantic / is_instance_schema

Method is_instance_schema

pydantic/json_schema.py:917–928  ·  view source on GitHub ↗

Handles JSON schema generation for a core schema that checks if a value is an instance of a class. Unless overridden in a subclass, this raises an error. Args: schema: The core schema. Returns: The generated JSON schema.

(self, schema: core_schema.IsInstanceSchema)

Source from the content-addressed store, hash-verified

915 return result
916
917 def is_instance_schema(self, schema: core_schema.IsInstanceSchema) -> JsonSchemaValue:
918 """Handles JSON schema generation for a core schema that checks if a value is an instance of a class.
919
920 Unless overridden in a subclass, this raises an error.
921
922 Args:
923 schema: The core schema.
924
925 Returns:
926 The generated JSON schema.
927 """
928 return self.handle_invalid_for_json_schema(schema, f'core_schema.IsInstanceSchema ({schema["cls"]})')
929
930 def is_subclass_schema(self, schema: core_schema.IsSubclassSchema) -> JsonSchemaValue:
931 """Handles JSON schema generation for a core schema that checks if a value is a subclass of a class.

Callers 15

get_secret_schemaMethod · 0.80
_enum_schemaMethod · 0.80
_ip_schemaMethod · 0.80
_path_schemaMethod · 0.80
_deque_schemaMethod · 0.80
_mapping_schemaMethod · 0.80
_fraction_schemaMethod · 0.80
_type_schemaMethod · 0.80
_sequence_schemaMethod · 0.80

Calls 1

Tested by 15

test_other_typeFunction · 0.64
test_json_or_pythonFunction · 0.64
test_enumFunction · 0.64
test_no_strict_checkFunction · 0.64
test_validate_jsonFunction · 0.64
test_is_instanceFunction · 0.64
test_is_instance_casesFunction · 0.64
test_is_instance_invalidFunction · 0.64
test_instancecheckFunction · 0.64