main commit
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-10-16 16:30:25 +09:00
parent 91c7e04474
commit 537e7b363f
1146 changed files with 45926 additions and 77196 deletions

View File

@@ -22,7 +22,7 @@ class Protocol(str, Enum):
pickle = 'pickle'
@deprecated('`load_str_bytes` is deprecated.', category=None)
@deprecated('load_str_bytes is deprecated.', category=PydanticDeprecatedSince20)
def load_str_bytes(
b: str | bytes,
*,
@@ -32,7 +32,7 @@ def load_str_bytes(
allow_pickle: bool = False,
json_loads: Callable[[str], Any] = json.loads,
) -> Any:
warnings.warn('`load_str_bytes` is deprecated.', category=PydanticDeprecatedSince20, stacklevel=2)
warnings.warn('load_str_bytes is deprecated.', DeprecationWarning, stacklevel=2)
if proto is None and content_type:
if content_type.endswith(('json', 'javascript')):
pass
@@ -46,17 +46,17 @@ def load_str_bytes(
if proto == Protocol.json:
if isinstance(b, bytes):
b = b.decode(encoding)
return json_loads(b) # type: ignore
return json_loads(b)
elif proto == Protocol.pickle:
if not allow_pickle:
raise RuntimeError('Trying to decode with pickle with allow_pickle=False')
bb = b if isinstance(b, bytes) else b.encode() # type: ignore
bb = b if isinstance(b, bytes) else b.encode()
return pickle.loads(bb)
else:
raise TypeError(f'Unknown protocol: {proto}')
@deprecated('`load_file` is deprecated.', category=None)
@deprecated('load_file is deprecated.', category=PydanticDeprecatedSince20)
def load_file(
path: str | Path,
*,
@@ -66,7 +66,7 @@ def load_file(
allow_pickle: bool = False,
json_loads: Callable[[str], Any] = json.loads,
) -> Any:
warnings.warn('`load_file` is deprecated.', category=PydanticDeprecatedSince20, stacklevel=2)
warnings.warn('load_file is deprecated.', DeprecationWarning, stacklevel=2)
path = Path(path)
b = path.read_bytes()
if content_type is None: