MCPcopy
hub / github.com/pydantic/pydantic / _calculate_keys

Method _calculate_keys

pydantic/v1/main.py:901–926  ·  view source on GitHub ↗
(
        self,
        include: Optional['MappingIntStrAny'],
        exclude: Optional['MappingIntStrAny'],
        exclude_unset: bool,
        update: Optional['DictStrAny'] = None,
    )

Source from the content-addressed store, hash-verified

899 yield dict_key, v
900
901 def _calculate_keys(
902 self,
903 include: Optional['MappingIntStrAny'],
904 exclude: Optional['MappingIntStrAny'],
905 exclude_unset: bool,
906 update: Optional['DictStrAny'] = None,
907 ) -> Optional[AbstractSet[str]]:
908 if include is None and exclude is None and exclude_unset is False:
909 return None
910
911 keys: AbstractSet[str]
912 if exclude_unset:
913 keys = self.__fields_set__.copy()
914 else:
915 keys = self.__dict__.keys()
916
917 if include is not None:
918 keys &= include.keys()
919
920 if update:
921 keys -= update.keys()
922
923 if exclude:
924 keys -= {k for k, v in exclude.items() if ValueItems.is_true(v)}
925
926 return keys
927
928 def __eq__(self, other: Any) -> bool:
929 if isinstance(other, BaseModel):

Callers 1

_iterMethod · 0.95

Calls 4

keysMethod · 0.80
copyMethod · 0.45
itemsMethod · 0.45
is_trueMethod · 0.45

Tested by

no test coverage detected