👷 添加ruff actions

🐛 分支应该是main而不是master

💄 auto fix by pre-commit hooks

🔥 dependabot.yml的registrys需要token,先删除
This commit is contained in:
Azide
2023-07-16 01:40:02 +08:00
committed by felinae98
parent 7d4eb7785c
commit e50eb5d70b
66 changed files with 69138 additions and 8051 deletions
+8 -14
View File
@@ -1,13 +1,13 @@
import datetime
from pathlib import Path
from nonebot_plugin_datastore import get_plugin_data
from nonebot_plugin_saa.utils import PlatformTarget
from sqlalchemy import JSON, ForeignKey, String, UniqueConstraint
from sqlalchemy.dialects.postgresql import JSONB
from sqlalchemy.orm import Mapped, mapped_column, relationship
from nonebot_plugin_saa.utils import PlatformTarget
from nonebot_plugin_datastore import get_plugin_data
from sqlalchemy.orm import Mapped, relationship, mapped_column
from sqlalchemy import JSON, String, ForeignKey, UniqueConstraint
from ..types import Category, Tag
from ..types import Tag, Category
Model = get_plugin_data().Model
get_plugin_data().set_migration_dir(Path(__file__).parent / "migrations")
@@ -25,9 +25,7 @@ class User(Model):
class Target(Model):
__table_args__ = (
UniqueConstraint("target", "platform_name", name="unique-target-constraint"),
)
__table_args__ = (UniqueConstraint("target", "platform_name", name="unique-target-constraint"),)
id: Mapped[int] = mapped_column(primary_key=True)
platform_name: Mapped[str] = mapped_column(String(20))
@@ -36,9 +34,7 @@ class Target(Model):
default_schedule_weight: Mapped[int] = mapped_column(default=10)
subscribes: Mapped[list["Subscribe"]] = relationship(back_populates="target")
time_weight: Mapped[list["ScheduleTimeWeight"]] = relationship(
back_populates="target"
)
time_weight: Mapped[list["ScheduleTimeWeight"]] = relationship(back_populates="target")
class ScheduleTimeWeight(Model):
@@ -55,9 +51,7 @@ class ScheduleTimeWeight(Model):
class Subscribe(Model):
__table_args__ = (
UniqueConstraint("target_id", "user_id", name="unique-subscribe-constraint"),
)
__table_args__ = (UniqueConstraint("target_id", "user_id", name="unique-subscribe-constraint"),)
id: Mapped[int] = mapped_column(primary_key=True)
target_id: Mapped[int] = mapped_column(ForeignKey("nonebot_bison_target.id"))
@@ -31,9 +31,7 @@ def upgrade():
sa.PrimaryKeyConstraint("id"),
)
with op.batch_alter_table("target", schema=None) as batch_op:
batch_op.add_column(
sa.Column("default_schedule_weight", sa.Integer(), nullable=True)
)
batch_op.add_column(sa.Column("default_schedule_weight", sa.Integer(), nullable=True))
batch_op.drop_column("last_schedule_time")
# ### end Alembic commands ###
@@ -42,9 +40,7 @@ def upgrade():
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("target", schema=None) as batch_op:
batch_op.add_column(
sa.Column("last_schedule_time", sa.DATETIME(), nullable=True)
)
batch_op.add_column(sa.Column("last_schedule_time", sa.DATETIME(), nullable=True))
batch_op.drop_column("default_schedule_weight")
op.drop_table("schedule_time_weight")
@@ -18,9 +18,7 @@ depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("target", schema=None) as batch_op:
batch_op.add_column(
sa.Column("last_schedule_time", sa.DateTime(timezone=True), nullable=True)
)
batch_op.add_column(sa.Column("last_schedule_time", sa.DateTime(timezone=True), nullable=True))
# ### end Alembic commands ###
@@ -7,8 +7,8 @@ Create Date: 2023-03-20 01:14:42.623789
"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.ext.automap import automap_base
from sqlalchemy.orm import Session
from sqlalchemy.ext.automap import automap_base
# revision identifiers, used by Alembic.
revision = "a5466912fad0"
@@ -17,9 +17,7 @@ depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table(
"nonebot_bison_scheduletimeweight", schema=None
) as batch_op:
with op.batch_alter_table("nonebot_bison_scheduletimeweight", schema=None) as batch_op:
batch_op.alter_column("target_id", existing_type=sa.INTEGER(), nullable=False)
batch_op.alter_column("start_time", existing_type=sa.TIME(), nullable=False)
batch_op.alter_column("end_time", existing_type=sa.TIME(), nullable=False)
@@ -30,9 +28,7 @@ def upgrade() -> None:
batch_op.alter_column("user_id", existing_type=sa.INTEGER(), nullable=False)
with op.batch_alter_table("nonebot_bison_target", schema=None) as batch_op:
batch_op.alter_column(
"default_schedule_weight", existing_type=sa.INTEGER(), nullable=False
)
batch_op.alter_column("default_schedule_weight", existing_type=sa.INTEGER(), nullable=False)
# ### end Alembic commands ###
@@ -40,17 +36,13 @@ def upgrade() -> None:
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("nonebot_bison_target", schema=None) as batch_op:
batch_op.alter_column(
"default_schedule_weight", existing_type=sa.INTEGER(), nullable=True
)
batch_op.alter_column("default_schedule_weight", existing_type=sa.INTEGER(), nullable=True)
with op.batch_alter_table("nonebot_bison_subscribe", schema=None) as batch_op:
batch_op.alter_column("user_id", existing_type=sa.INTEGER(), nullable=True)
batch_op.alter_column("target_id", existing_type=sa.INTEGER(), nullable=True)
with op.batch_alter_table(
"nonebot_bison_scheduletimeweight", schema=None
) as batch_op:
with op.batch_alter_table("nonebot_bison_scheduletimeweight", schema=None) as batch_op:
batch_op.alter_column("weight", existing_type=sa.INTEGER(), nullable=True)
batch_op.alter_column("end_time", existing_type=sa.TIME(), nullable=True)
batch_op.alter_column("start_time", existing_type=sa.TIME(), nullable=True)
@@ -8,8 +8,8 @@ Create Date: 2023-03-02 14:04:16.492133
import sqlalchemy as sa
from alembic import op
from sqlalchemy import select
from sqlalchemy.ext.automap import automap_base
from sqlalchemy.orm import Session
from sqlalchemy.ext.automap import automap_base
# revision identifiers, used by Alembic.
revision = "bd92923c218f"
@@ -1,16 +1,16 @@
""" nbesf is Nonebot Bison Enchangable Subscribes File! ver.1"""
from functools import partial
from typing import Any
from functools import partial
from nonebot.log import logger
from nonebot_plugin_saa import TargetQQGroup, TargetQQPrivate
from pydantic import BaseModel
from nonebot_plugin_saa import TargetQQGroup, TargetQQPrivate
from ....types import Category, Tag
from ...db_config import SubscribeDupException, config
from ..utils import NBESFParseErr
from ....types import Tag, Category
from .base import NBESFBase, SubReceipt
from ...db_config import SubscribeDupException, config
# ===== nbesf 定义格式 ====== #
NBESF_VERSION = 1
@@ -65,7 +65,6 @@ class SubGroup(
async def subs_receipt_gen(nbesf_data: SubGroup):
for item in nbesf_data.groups:
match item.user.type:
case "group":
user = TargetQQGroup(group_id=item.user.uid)
@@ -85,9 +84,7 @@ async def subs_receipt_gen(nbesf_data: SubGroup):
tags=sub.tags,
)
try:
await config.add_subscribe(
receipt.user, **receipt.dict(exclude={"user"})
)
await config.add_subscribe(receipt.user, **receipt.dict(exclude={"user"}))
except SubscribeDupException:
logger.warning(f"!添加订阅条目 {repr(receipt)} 失败: 相同的订阅已存在")
except Exception as e:
@@ -1,16 +1,16 @@
""" nbesf is Nonebot Bison Enchangable Subscribes File! ver.2"""
from functools import partial
from typing import Any
from functools import partial
from nonebot.log import logger
from nonebot_plugin_saa.utils import AllSupportedPlatformTarget
from pydantic import BaseModel
from nonebot_plugin_saa.utils import AllSupportedPlatformTarget
from ....types import Category, Tag
from ...db_config import SubscribeDupException, config
from ..utils import NBESFParseErr
from ....types import Tag, Category
from .base import NBESFBase, SubReceipt
from ...db_config import SubscribeDupException, config
# ===== nbesf 定义格式 ====== #
NBESF_VERSION = 2
@@ -57,7 +57,6 @@ class SubGroup(NBESFBase):
async def subs_receipt_gen(nbesf_data: SubGroup):
for item in nbesf_data.groups:
sub_receipt = partial(SubReceipt, user=item.user_target)
for sub in item.subs:
@@ -69,9 +68,7 @@ async def subs_receipt_gen(nbesf_data: SubGroup):
tags=sub.tags,
)
try:
await config.add_subscribe(
receipt.user, **receipt.dict(exclude={"user"})
)
await config.add_subscribe(receipt.user, **receipt.dict(exclude={"user"}))
except SubscribeDupException:
logger.warning(f"!添加订阅条目 {repr(receipt)} 失败: 相同的订阅已存在")
except Exception as e: