Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: 使用 ruff 格式化代码 #70

Merged
merged 1 commit into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
needs: test
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe
with:
jobs: ${{ toJSON(needs) }}
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe
with:
jobs: ${{ toJSON(needs) }}
24 changes: 11 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,28 @@ ci:
autoupdate_schedule: weekly
autoupdate_commit_msg: "chore: auto update by pre-commit hooks"
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.286
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
stages: [commit]

- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
stages: [commit]

- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
stages: [commit]

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0
hooks:
- id: prettier
types_or: [markdown]

- repo: https://github.com/asottile/pyupgrade
rev: v3.9.0
hooks:
- id: pyupgrade
args: [--py38-plus]

- repo: https://github.com/hadialqattan/pycln
rev: v2.1.6
hooks:
- id: pycln
args: [--config, pyproject.toml]
types_or: [javascript, jsx, ts, tsx, markdown, yaml, json]
stages: [commit]
7 changes: 2 additions & 5 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
"type": "python",
"request": "launch",
"module": "nb_cli",
"args": [
"run",
"--reload"
],
"args": ["run", "--reload"],
"justMyCode": false
},
{
Expand All @@ -22,4 +19,4 @@
"module": "pytest"
}
]
}
}
7 changes: 1 addition & 6 deletions nonebot_plugin_treehelp/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,7 @@ def map_command_to_plguin(plugin: "Plugin"):
def format_description(plugins: List["Plugin"]) -> str:
"""格式化描述"""
return "\n".join(
sorted(
map(
lambda x: f"{x.metadata.name} # {x.metadata.description}", # type: ignore
plugins,
)
)
sorted(f"{x.metadata.name} # {x.metadata.description}" for x in plugins)
)


Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ pythonVersion = "3.8"
pythonPlatform = "All"
typeCheckingMode = "basic"

[tool.ruff]
select = ["E", "W", "F", "UP", "C", "T", "PYI", "Q"]
ignore = ["E402", "E501", "C901", "UP037"]

[tool.nonebot]
adapters = [
{ name = "OneBot V11", module_name = "nonebot.adapters.onebot.v11" },
Expand Down
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import nonebot
import pytest
from nonebug import NONEBOT_INIT_KWARGS, App
from nonebug.app import App

from .utils import clear_plugins

Expand Down
2 changes: 1 addition & 1 deletion tests/plugins/nested/plugins/sub2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from nonebot.plugin import PluginMetadata

from .sub1 import plugin_id
from .sub1 import plugin_id # noqa: F401

__plugin_meta__ = PluginMetadata(
name="功能二",
Expand Down
4 changes: 2 additions & 2 deletions tests/test_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

async def test_help(app: App):
"""测试帮助"""
from nonebot_plugin_treehelp import __plugin_meta__, help_cmd
from nonebot_plugin_treehelp import help_cmd

async with app.test_matcher(help_cmd) as ctx:
bot = ctx.create_bot()
message = message = make_fake_message()("/help")
event = make_fake_event(_message=message)()

ctx.receive_event(bot, event)
ctx.should_call_send(event, f"插件:\n帮助 # 获取插件帮助信息", True)
ctx.should_call_send(event, "插件:\n帮助 # 获取插件帮助信息", True)
ctx.should_finished()


Expand Down