Skip to content

Commit

Permalink
style: 使用 ruff 0.7.0 格式化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
he0119 committed Oct 22, 2024
1 parent b153939 commit 279913d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 19 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ ci:
autoupdate_commit_msg: "chore: auto update by pre-commit hooks"
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.2
rev: v0.7.0
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
stages: [commit]
stages: [pre-commit]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
types_or: [javascript, jsx, ts, tsx, markdown, yaml, json]
stages: [commit]
stages: [pre-commit]
6 changes: 3 additions & 3 deletions docker/plugin_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
经测试可以直接在 Python 3.10+ 环境下运行,无需额外依赖。
"""
# ruff: noqa: T201, ASYNC101
# ruff: noqa: T201

import asyncio
import json
import re
import os
import re
from asyncio import create_subprocess_shell, subprocess
from pathlib import Path
from urllib.request import urlopen
Expand Down Expand Up @@ -276,7 +276,7 @@ async def run(self):

return self._run, self._lines_output

async def command(self, cmd: str, timeout: int = 300) -> tuple[bool, str, str]:
async def command(self, cmd: str, timeout: int = 300) -> tuple[bool, str, str]: # noqa: ASYNC109
"""执行命令
Args:
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def load_plugin(nonebug_init: None) -> set["Plugin"]:
)


@pytest.fixture()
@pytest.fixture
async def app(app: App, tmp_path: Path, mocker: MockerFixture):
from src.plugins.github import plugin_config

Expand Down Expand Up @@ -117,7 +117,7 @@ def _clear_cache(app: App):
check_url.cache_clear()


@pytest.fixture()
@pytest.fixture
def mocked_api(respx_mock: MockRouter):
respx_mock.get("exception", name="exception").mock(side_effect=httpx.ConnectError)
respx_mock.get(
Expand Down
2 changes: 1 addition & 1 deletion tests/github/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pytest_mock import MockerFixture


@pytest.fixture()
@pytest.fixture
def mock_installation(mocker: MockerFixture):
mock_installation = mocker.MagicMock()
mock_installation.id = 123
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# ruff: noqa: ASYNC101
import json
from pathlib import Path
from typing import Any


import pytest
from inline_snapshot import snapshot
from nonebug import App
import pytest
from pytest_mock import MockerFixture
from respx import MockRouter

Expand All @@ -18,7 +16,7 @@ def check_json_data(file: Path, data: Any) -> None:
assert json.load(f) == data


@pytest.fixture()
@pytest.fixture
def mock_pull(mocker: MockerFixture):
mock_pull = mocker.MagicMock()
mock_pull.head.ref = "publish/issue1"
Expand All @@ -31,8 +29,8 @@ async def test_resolve_conflict_pull_requests_adapter(
app: App, mocker: MockerFixture, mocked_api: MockRouter, tmp_path: Path, mock_pull
) -> None:
from src.plugins.github import plugin_config
from src.plugins.github.models import GithubHandler, RepoInfo
from src.plugins.github.plugins.publish.utils import resolve_conflict_pull_requests
from src.plugins.github.models import RepoInfo, GithubHandler

mock_subprocess_run = mocker.patch("subprocess.run")
mock_result = mocker.MagicMock()
Expand Down Expand Up @@ -162,8 +160,8 @@ async def test_resolve_conflict_pull_requests_bot(
app: App, mocker: MockerFixture, mocked_api: MockRouter, tmp_path: Path, mock_pull
) -> None:
from src.plugins.github import plugin_config
from src.plugins.github.models import GithubHandler, RepoInfo
from src.plugins.github.plugins.publish.utils import resolve_conflict_pull_requests
from src.plugins.github.models import RepoInfo, GithubHandler

mock_subprocess_run = mocker.patch("subprocess.run")
mock_result = mocker.MagicMock()
Expand Down Expand Up @@ -288,8 +286,8 @@ async def test_resolve_conflict_pull_requests_plugin(
app: App, mocker: MockerFixture, mocked_api: MockRouter, tmp_path: Path, mock_pull
) -> None:
from src.plugins.github import plugin_config
from src.plugins.github.models import GithubHandler, RepoInfo
from src.plugins.github.plugins.publish.utils import resolve_conflict_pull_requests
from src.plugins.github.models import RepoInfo, GithubHandler

mock_subprocess_run = mocker.patch("subprocess.run")
mock_result = mocker.MagicMock()
Expand Down Expand Up @@ -413,8 +411,8 @@ async def test_resolve_conflict_pull_requests_draft(
app: App, mocker: MockerFixture, mocked_api: MockRouter, tmp_path: Path
) -> None:
from src.plugins.github import plugin_config
from src.plugins.github.models import GithubHandler, RepoInfo
from src.plugins.github.plugins.publish.utils import resolve_conflict_pull_requests
from src.plugins.github.models import RepoInfo, GithubHandler

mock_subprocess_run = mocker.patch("subprocess.run")
mock_result = mocker.MagicMock()
Expand Down Expand Up @@ -476,8 +474,8 @@ async def test_resolve_conflict_pull_requests_ref(
app: App, mocker: MockerFixture, mocked_api: MockRouter, tmp_path: Path
) -> None:
from src.plugins.github import plugin_config
from src.plugins.github.models import GithubHandler, RepoInfo
from src.plugins.github.plugins.publish.utils import resolve_conflict_pull_requests
from src.plugins.github.models import RepoInfo, GithubHandler

mock_subprocess_run = mocker.patch("subprocess.run")
mock_result = mocker.MagicMock()
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/store_test/test_store_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def load_json(name: str) -> dict:
return json.load(f)


@pytest.fixture()
@pytest.fixture
def mocked_store_data(
tmp_path: Path,
mocker: MockerFixture,
Expand Down

0 comments on commit 279913d

Please sign in to comment.