Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/pydantic_core/__init__.py: 96%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

56 statements  

1from __future__ import annotations 

2 

3import sys as _sys 

4from typing import Any as _Any 

5 

6from ._pydantic_core import ( 

7 ArgsKwargs, 

8 MultiHostUrl, 

9 PydanticCustomError, 

10 PydanticKnownError, 

11 PydanticOmit, 

12 PydanticSerializationError, 

13 PydanticSerializationUnexpectedValue, 

14 PydanticUndefined, 

15 PydanticUndefinedType, 

16 PydanticUseDefault, 

17 SchemaError, 

18 SchemaSerializer, 

19 SchemaValidator, 

20 Some, 

21 TzInfo, 

22 Url, 

23 ValidationError, 

24 __version__, 

25 from_json, 

26 to_json, 

27 to_jsonable_python, 

28 validate_core_schema, 

29) 

30from .core_schema import CoreConfig, CoreSchema, CoreSchemaType, ErrorType 

31 

32if _sys.version_info < (3, 11): 

33 from typing_extensions import NotRequired as _NotRequired 

34else: 

35 from typing import NotRequired as _NotRequired 

36 

37if _sys.version_info < (3, 12): 

38 from typing_extensions import TypedDict as _TypedDict 

39else: 

40 from typing import TypedDict as _TypedDict 

41 

42__all__ = [ 

43 '__version__', 

44 'CoreConfig', 

45 'CoreSchema', 

46 'CoreSchemaType', 

47 'SchemaValidator', 

48 'SchemaSerializer', 

49 'Some', 

50 'Url', 

51 'MultiHostUrl', 

52 'ArgsKwargs', 

53 'PydanticUndefined', 

54 'PydanticUndefinedType', 

55 'SchemaError', 

56 'ErrorDetails', 

57 'InitErrorDetails', 

58 'ValidationError', 

59 'PydanticCustomError', 

60 'PydanticKnownError', 

61 'PydanticOmit', 

62 'PydanticUseDefault', 

63 'PydanticSerializationError', 

64 'PydanticSerializationUnexpectedValue', 

65 'TzInfo', 

66 'to_json', 

67 'from_json', 

68 'to_jsonable_python', 

69 'validate_core_schema', 

70] 

71 

72 

73class ErrorDetails(_TypedDict): 

74 type: str 

75 """ 

76 The type of error that occurred, this is an identifier designed for 

77 programmatic use that will change rarely or never. 

78 

79 `type` is unique for each error message, and can hence be used as an identifier to build custom error messages. 

80 """ 

81 loc: tuple[int | str, ...] 

82 """Tuple of strings and ints identifying where in the schema the error occurred.""" 

83 msg: str 

84 """A human readable error message.""" 

85 input: _Any 

86 """The input data at this `loc` that caused the error.""" 

87 ctx: _NotRequired[dict[str, _Any]] 

88 """ 

89 Values which are required to render the error message, and could hence be useful in rendering custom error messages. 

90 Also useful for passing custom error data forward. 

91 """ 

92 url: _NotRequired[str] 

93 """ 

94 The documentation URL giving information about the error. No URL is available if 

95 a [`PydanticCustomError`][pydantic_core.PydanticCustomError] is used. 

96 """ 

97 

98 

99class InitErrorDetails(_TypedDict): 

100 type: str | PydanticCustomError 

101 """The type of error that occurred, this should be a "slug" identifier that changes rarely or never.""" 

102 loc: _NotRequired[tuple[int | str, ...]] 

103 """Tuple of strings and ints identifying where in the schema the error occurred.""" 

104 input: _Any 

105 """The input data at this `loc` that caused the error.""" 

106 ctx: _NotRequired[dict[str, _Any]] 

107 """ 

108 Values which are required to render the error message, and could hence be useful in rendering custom error messages. 

109 Also useful for passing custom error data forward. 

110 """ 

111 

112 

113class ErrorTypeInfo(_TypedDict): 

114 """ 

115 Gives information about errors. 

116 """ 

117 

118 type: ErrorType 

119 """The type of error that occurred, this should a "slug" identifier that changes rarely or never.""" 

120 message_template_python: str 

121 """String template to render a human readable error message from using context, when the input is Python.""" 

122 example_message_python: str 

123 """Example of a human readable error message, when the input is Python.""" 

124 message_template_json: _NotRequired[str] 

125 """String template to render a human readable error message from using context, when the input is JSON data.""" 

126 example_message_json: _NotRequired[str] 

127 """Example of a human readable error message, when the input is JSON data.""" 

128 example_context: dict[str, _Any] | None 

129 """Example of context values.""" 

130 

131 

132class MultiHostHost(_TypedDict): 

133 """ 

134 A host part of a multi-host URL. 

135 """ 

136 

137 username: str | None 

138 """The username part of this host, or `None`.""" 

139 password: str | None 

140 """The password part of this host, or `None`.""" 

141 host: str | None 

142 """The host part of this host, or `None`.""" 

143 port: int | None 

144 """The port part of this host, or `None`."""