- 新增 SystemNotification 模型,实现系统通知的数据存储 - 管理后台新增通知相关接口,支持通知的增删改查 - 用户端新增接口,获取最新激活通知并支持标记已读 - 在前端首页添加全局通知弹窗,实现通知自动轮询及已读同步 - 生成历史记录中兼容支持图片缩略图及新旧图片格式 - 优化后台图片同步逻辑,新增缩略图生成与存储 - 支持上传参考图的拖拽、粘贴、多文件上传及排序功能 - 增加购买积分页面入口及菜单项,调整菜单结构 - 日志系统由 Redis 列表迁移为有序集合,保留 30 天日志 - 优化日志页面样式,提升可读性及滚动体验 - 调整部分模板布局为自定义滚动条容器,增强视觉一致性
73 lines
2.0 KiB
Python
73 lines
2.0 KiB
Python
from __future__ import annotations
|
|
|
|
import warnings
|
|
|
|
from . import __version__
|
|
|
|
|
|
def deprecate(
|
|
deprecated: str,
|
|
when: int | None,
|
|
replacement: str | None = None,
|
|
*,
|
|
action: str | None = None,
|
|
plural: bool = False,
|
|
stacklevel: int = 3,
|
|
) -> None:
|
|
"""
|
|
Deprecations helper.
|
|
|
|
:param deprecated: Name of thing to be deprecated.
|
|
:param when: Pillow major version to be removed in.
|
|
:param replacement: Name of replacement.
|
|
:param action: Instead of "replacement", give a custom call to action
|
|
e.g. "Upgrade to new thing".
|
|
:param plural: if the deprecated thing is plural, needing "are" instead of "is".
|
|
|
|
Usually of the form:
|
|
|
|
"[deprecated] is deprecated and will be removed in Pillow [when] (yyyy-mm-dd).
|
|
Use [replacement] instead."
|
|
|
|
You can leave out the replacement sentence:
|
|
|
|
"[deprecated] is deprecated and will be removed in Pillow [when] (yyyy-mm-dd)"
|
|
|
|
Or with another call to action:
|
|
|
|
"[deprecated] is deprecated and will be removed in Pillow [when] (yyyy-mm-dd).
|
|
[action]."
|
|
"""
|
|
|
|
is_ = "are" if plural else "is"
|
|
|
|
if when is None:
|
|
removed = "a future version"
|
|
elif when <= int(__version__.split(".")[0]):
|
|
msg = f"{deprecated} {is_} deprecated and should be removed."
|
|
raise RuntimeError(msg)
|
|
elif when == 13:
|
|
removed = "Pillow 13 (2026-10-15)"
|
|
elif when == 14:
|
|
removed = "Pillow 14 (2027-10-15)"
|
|
else:
|
|
msg = f"Unknown removal version: {when}. Update {__name__}?"
|
|
raise ValueError(msg)
|
|
|
|
if replacement and action:
|
|
msg = "Use only one of 'replacement' and 'action'"
|
|
raise ValueError(msg)
|
|
|
|
if replacement:
|
|
action = f". Use {replacement} instead."
|
|
elif action:
|
|
action = f". {action.rstrip('.')}."
|
|
else:
|
|
action = ""
|
|
|
|
warnings.warn(
|
|
f"{deprecated} {is_} deprecated and will be removed in {removed}{action}",
|
|
DeprecationWarning,
|
|
stacklevel=stacklevel,
|
|
)
|