Skip to content

Commit a07a3d1

Browse files
committed
🎨 format
1 parent 22511f4 commit a07a3d1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+789
-724
lines changed

example/plugins/demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def id(self) -> str:
328328
async def message_provider(self, event, state, bot: Bot, use_origin: bool = False):
329329
if not isinstance(event, GroupMessageDeleteEvent):
330330
return None
331-
return UniMessage(f"/recall {str(event.group_id)} {str(event.user_id)} {str(event.message_id)}")
331+
return UniMessage(f"/recall {event.group_id} {event.user_id} {event.message_id}")
332332

333333

334334
recall = on_alconna(

pdm.lock

Lines changed: 100 additions & 76 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 103 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ build-backend = "pdm.backend"
3333
[tool.pdm]
3434
[tool.pdm.dev-dependencies]
3535
dev = [
36-
"isort>=5.13.2",
37-
"black>=24.4.2",
36+
"isort!=6.0.0",
37+
"black>=25.1.0",
3838
"loguru>=0.7.2",
39-
"ruff>=0.4.2",
39+
"ruff>=0.8.4",
4040
"nonemoji>=0.1.4",
4141
"pre-commit>=3.7.0",
4242
"nonebug>=0.3.7",
@@ -52,12 +52,13 @@ dev = [
5252
"nonebot-adapter-dodo>=0.2.1",
5353
"nonebot-adapter-feishu>=2.6.0",
5454
"nonebot-adapter-kaiheila>=0.3.4",
55+
"nonebot-adapter-mail>=1.0.0a7",
5556
"nonebot-adapter-mirai>=2.3.3",
5657
"nonebot-adapter-minecraft>=1.3.2",
5758
"nonebot-adapter-onebot>=2.4.5",
58-
"nonebot-adapter-qq>=1.5.3",
59+
"nonebot-adapter-qq>=1.6.2",
5960
"nonebot-adapter-red>=0.9.0",
60-
"nonebot-adapter-satori>=0.13.0",
61+
"nonebot-adapter-satori>=0.13.4",
6162
"nonebot-adapter-telegram>=0.1.0b18",
6263
"nonebot-adapter-kritor>=0.3.2",
6364
"nonebot-adapter-tailchat>=0.1.0b12",
@@ -67,7 +68,7 @@ dev = [
6768
"pytest-mock>=3.14.0",
6869
"nonebot-plugin-localstore>=0.7.1",
6970
"pyyaml>=6.0.1",
70-
"nonebot-adapter-mail>=1.0.0a3",
71+
"fix-future-annotations>=0.5.0",
7172
]
7273
[tool.pdm.build]
7374
includes = ["src/nonebot_plugin_alconna"]
@@ -96,8 +97,102 @@ line-length = 120
9697
target-version = "py39"
9798

9899
[tool.ruff.lint]
99-
select = ["E", "W", "F", "UP", "C", "T", "PYI", "PT", "Q"]
100-
ignore = ["C901", "T201", "E731", "E402", "PT023"]
100+
select = [
101+
"F", # pyflakes
102+
"E", # pycodestyle errors
103+
"W", # pycodestyle warnings
104+
# "I", # isort
105+
"N", # PEP8-naming
106+
"UP", # pyupgrade
107+
"YTT", # flake8-2020
108+
"ASYNC", # flake8-async
109+
# "S", # flake8-bandit
110+
"BLE", # flake8-blind-except
111+
# "FBT", # flake8-boolean-trap
112+
"B", # flake8-bugbear
113+
"A", # flake8-builtins
114+
"COM", # flake8-commas
115+
"C4", # flake8-comprehensions
116+
"DTZ", # flake8-datetimez
117+
"T10", # flake8-debugger
118+
# "FA", # flake8-future-annotations
119+
"ISC", # flake8-implicit-str-concat
120+
"ICN", # flake8-import-conventions
121+
"PIE", # flake8-pie
122+
"T20", # flake8-print
123+
"PYI", # flake8-pyi
124+
"Q", # flake8-quotes
125+
"RSE", # flake8-raise
126+
"RET", # flake8-return
127+
"SLOT", # flake8-slots
128+
"SIM", # flake8-simplify
129+
"TID", # flake8-tidy-imports
130+
# "TC", # flake8-type-checking
131+
# "ARG", # flake8-unused-arguments
132+
"PTH", # flake8-use-pathlib
133+
# "ERA", # eradicate
134+
"PD", # pandas-vet
135+
"PGH", # pygrep-hooks
136+
"PL", # pylint
137+
"TRY", # tryceratops
138+
"FLY", # flynt
139+
"FAST", # FastAPI
140+
"PERF", # Perflint
141+
"FURB", # refurb
142+
"RUF", # Ruff-specific rules
143+
]
144+
ignore = [
145+
"C901",
146+
"T201",
147+
"E731",
148+
"PT023",
149+
"B010", # Do not call `setattr` with a constant attribute value.
150+
"SIM105", # Use `contextlib.suppress`
151+
"B008", # Do not perform function call in argument defaults
152+
"RUF100", # Unused `noqa` directive
153+
"TC003", # Move xxx into a type-checking block
154+
"E402", # module level import not at top of file
155+
"E501", # 过长的行由 ruff format 处理, 剩余的都是字符串
156+
"UP035", # pyupgrade, 但 typing.Callable 的导入会报错
157+
"TRY003",
158+
"TRY301", # 为啥非要把 raise 丢进另外一个 inner fn 里
159+
"BLE001", # except Exception as e
160+
"PGH003", # 要求 `# type: ignore` 提供理由,但 pyright 和 mypy 等都不是统一标准。
161+
"PLC0414", # 用 import-as 表示 re-export
162+
"N818", # 要求所有自定义错误以 Error 作后缀,但我们不这么做
163+
"RET502", # return = return None
164+
"RET503", # 就要 implicit return none
165+
"PLC0105", # 我们已经用 R 表示协变,Q 表示逆变了
166+
"PLR0913", # 参数就那么多的,你用 builder 什么的不是更逆天?
167+
"SIM108", # 迫真 simplicy
168+
"RUF001", # String contains ambiguous `,` (FULLWIDTH COMMA). Did you mean `,` (COMMA)?
169+
"RUF002", # Docstring contains ambiguous `,` (FULLWIDTH COMMA). Did you mean `,` (COMMA)?
170+
"RUF009", # 我不想要额外的全局变量。
171+
"UP038", # instance(..., X | Y) 还是太超前了
172+
"RUF003", # 中文注释里用全角符号怎么你了
173+
"SLOT000", # 动态类型需求,主要是 json5 backend
174+
"PLR0911", "PLR0912", "PLR0915", # 复杂度高点怎么你了
175+
"PYI041", # int 和 float 在运行时的类型没有交集(互不成立 issubclass)
176+
"PLW2901", # shallow 怎么你了
177+
"S101", # assert 怎么你了,非要 RuntimeError 吗
178+
"PLR2004", # magic number 怎么你了
179+
"TRY004", # 我要抛啥错误我清楚
180+
"COM812", # 强制尾随逗号
181+
"TID252", # 相对导入
182+
"ISC001", # format warning
183+
"N801", # Class name should use CapWords convention
184+
"N802", # Function name should be lowercase
185+
"N804", # First argument of a class method should be named `cls`
186+
"N805", # First argument of a method should be named `self`
187+
"N806", # Variable in function should be lowercase
188+
]
189+
flake8-quotes = { inline-quotes = "double", multiline-quotes = "double" }
190+
191+
[tool.ruff.lint.flake8-annotations]
192+
mypy-init-return = true
193+
194+
[tool.ruff.lint.flake8-builtins]
195+
builtins-ignorelist = ["id"]
101196

102197
[tool.pyright]
103198
pythonVersion = "3.9"

src/nonebot_plugin_alconna/adapters/console.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
def markup(self, text: Text):
1010
if text.extract_most_style().startswith("markdown"):
1111
return MessageSegment.markup(text.text, style=text.extract_most_style().split(":")[1])
12+
return None
1213

1314

1415
def markdown(self, text: Text):
1516
if text.extract_most_style().startswith("markdown"):
1617
return MessageSegment.markdown(text.text, code_theme=text.extract_most_style().split(":")[1])
18+
return None
1719

1820

1921
Markup = TextSegmentPattern("markup", MessageSegment, MessageSegment.markup, markup)

src/nonebot_plugin_alconna/adapters/discord.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def _translate_args(args: Args) -> list[AnyCommandOption]:
115115
)
116116
)
117117
continue
118-
elif arg.value == ANY:
118+
if arg.value == ANY:
119119
result.append(
120120
StringOption(
121121
name=arg.name,

src/nonebot_plugin_alconna/adapters/kook.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ def mention_channel(channel_id: str):
3131
def emoji(id: str, name: str = ""):
3232
if name:
3333
return MessageSegment.KMarkdown(f"(emj){name}(emj)[{id}]")
34-
else:
35-
return MessageSegment.KMarkdown(f":{id}:")
34+
return MessageSegment.KMarkdown(f":{id}:")
3635

3736

3837
Mention = At = SegmentPattern("mention", _Mention, UniAt, MessageSegment.mention)
@@ -53,6 +52,7 @@ def emoji(id: str, name: str = ""):
5352
def kmarkdown(self, text: UniText):
5453
if text.extract_most_style() == "markdown":
5554
return MessageSegment.KMarkdown(text.text, text.text)
55+
return None
5656

5757

5858
KMarkdown = TextSegmentPattern("kmarkdown", _KMarkdown, MessageSegment.KMarkdown, kmarkdown)

src/nonebot_plugin_alconna/adapters/kritor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
def markdown(self, x: Text):
5151
if x.extract_most_style() == "markdown":
5252
return MessageSegment.markdown(x.text)
53+
return None
5354

5455

5556
Markdown = TextSegmentPattern("markdown", _Markdown, MessageSegment.markdown, markdown)

src/nonebot_plugin_alconna/adapters/mail.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
def is_html(self, text: Text):
1010
if text.extract_most_style().startswith("html"):
1111
return MessageSegment.html(text.text)
12+
return None
1213

1314

1415
Markup = TextSegmentPattern("html", MessageSegment, MessageSegment.html, is_html)

src/nonebot_plugin_alconna/adapters/qq.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
def markdown(self, x: Text):
5252
if x.extract_most_style() == "markdown":
5353
return MessageSegment.markdown(x.text)
54+
return None
5455

5556

5657
Markdown = TextSegmentPattern("markdown", _Markdown, MessageSegment.markdown, markdown)

src/nonebot_plugin_alconna/adapters/satori.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ def link(self, x: Text):
4747
if x.extract_most_style() == "link":
4848
if not getattr(x, "_children", []):
4949
return MessageSegment.link(x.text)
50-
else:
51-
return MessageSegment.link(x.text, x._children[0].text) # type: ignore
50+
return MessageSegment.link(x.text, x._children[0].text) # type: ignore
51+
return None
5252

5353

5454
Link = TextSegmentPattern("link", _Link, MessageSegment.link, link)

0 commit comments

Comments
 (0)