MCPcopy
hub / github.com/pydantic/pydantic / __repr_args__

Method __repr_args__

pydantic/fields.py:835–869  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

833 return copied # pyright: ignore[reportReturnType]
834
835 def __repr_args__(self) -> ReprArgs:
836 yield 'annotation', _repr.PlainRepr(_repr.display_as_type(self.annotation))
837 yield 'required', self.is_required()
838
839 for s in self.__slots__:
840 # TODO: properly make use of the protocol (https://rich.readthedocs.io/en/stable/pretty.html#rich-repr-protocol)
841 # By yielding a three-tuple:
842 if s in (
843 'annotation',
844 '_attributes_set',
845 '_qualifiers',
846 '_complete',
847 '_original_assignment',
848 '_original_annotation',
849 '_final',
850 ):
851 continue
852 elif s == 'metadata' and not self.metadata:
853 continue
854 elif s == 'repr' and self.repr is True:
855 continue
856 if s == 'frozen' and self.frozen is False:
857 continue
858 if s == 'validation_alias' and self.validation_alias == self.alias:
859 continue
860 if s == 'serialization_alias' and self.serialization_alias == self.alias:
861 continue
862 if s == 'default' and self.default is not PydanticUndefined:
863 yield 'default', self.default
864 elif s == 'default_factory' and self.default_factory is not None:
865 yield 'default_factory', _repr.PlainRepr(_repr.display_as_type(self.default_factory))
866 else:
867 value = getattr(self, s)
868 if value is not None and value is not PydanticUndefined:
869 yield s, value
870
871
872class _EmptyKwargs(TypedDict):

Callers

nothing calls this directly

Calls 1

is_requiredMethod · 0.95

Tested by

no test coverage detected