Skip to content

Commit 2daa93a

Browse files
committed
feat: lint for ruff standard
1 parent 4968afd commit 2daa93a

File tree

21 files changed

+637
-152
lines changed

21 files changed

+637
-152
lines changed

.vscode/settings.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
{
2-
"black-formatter.args": ["--line-length", "150"]
2+
"[python]": {
3+
"editor.formatOnSave": true,
4+
"editor.defaultFormatter": "charliermarsh.ruff"
5+
},
6+
"python-envs.defaultEnvManager": "ms-python.python:poetry",
7+
"python-envs.defaultPackageManager": "ms-python.python:poetry",
8+
"python-envs.pythonProjects": []
39
}

examples/proxy_updater/proxy.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import asyncio
2+
23
from mitmproxy.http import HTTPFlow, Response
34

45
from proxy_updater import updater
@@ -18,6 +19,11 @@ async def request(self, flow: HTTPFlow):
1819
if flow.request.host in self.wahlap_hosts and flow.request.path.startswith("/wc_auth/oauth/callback/maimai-dx"):
1920
# prevent infinite loop if the server and client are both using the proxy (user is testing in the same machine)
2021
if not flow.request.headers.get("Flag", None):
21-
r, t, code, state = flow.request.query["r"], flow.request.query["t"], flow.request.query["code"], flow.request.query["state"]
22+
r, t, code, state = (
23+
flow.request.query["r"],
24+
flow.request.query["t"],
25+
flow.request.query["code"],
26+
flow.request.query["state"],
27+
)
2228
asyncio.ensure_future(updater.update_prober(r, t, code, state))
2329
flow.response = Response.make(200, prompt.encode("gbk"), {"Content-Type": "text/plain"})

examples/proxy_updater/updater.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
async def generate_url():
1818
threaded_maimai = MaimaiClientMultithreading(timeout=300)
1919
url = await threaded_maimai.wechat()
20-
print(f"\033[32mPlease visit the following URL in Wechat to authorize: \033[0m")
20+
print("\033[32mPlease visit the following URL in Wechat to authorize: \033[0m")
2121
print(url)
2222

2323

@@ -38,19 +38,23 @@ async def update_prober(r: str, t: str, code: str, state: str):
3838
# establish the tasks of updating the prober according to the configuration
3939
update_tasks = []
4040
if token := os.getenv("DIVINGFISH_IMPORT_TOKEN"):
41-
task = asyncio.create_task(maimai.updates(PlayerIdentifier(credentials=token), scores.scores, DivingFishProvider()))
41+
task = asyncio.create_task(
42+
maimai.updates(PlayerIdentifier(credentials=token), scores.scores, DivingFishProvider())
43+
)
4244
update_tasks.append(task)
4345
if token := os.getenv("LXNS_PERSONAL_TOKEN"):
4446
task1 = asyncio.create_task(maimai.updates(PlayerIdentifier(credentials=token), records, LXNSProvider()))
45-
task2 = asyncio.create_task(maimai.updates(PlayerIdentifier(credentials=token), scores.scores, LXNSProvider()))
47+
task2 = asyncio.create_task(
48+
maimai.updates(PlayerIdentifier(credentials=token), scores.scores, LXNSProvider())
49+
)
4650
update_tasks.append(task1)
4751
update_tasks.append(task2)
4852
asyncio.gather(*update_tasks)
49-
print(f"\033[32mProber updated successfully.\033[0m")
50-
except (ConnectError, ReadTimeout) as e:
51-
print(f"\033[31mConnection to the server timed out.\033[0m")
53+
print("\033[32mProber updated successfully.\033[0m")
54+
except (ConnectError, ReadTimeout):
55+
print("\033[31mConnection to the server timed out.\033[0m")
5256
except (InvalidPlayerIdentifierError, PrivacyLimitationError, InvalidWechatTokenError) as e:
5357
print(f"\033[31m{e}.\033[0m")
54-
except Exception as e:
58+
except Exception:
5559
traceback.print_exc()
56-
print(f"\033[31mAn unexpected error occurred.\033[0m")
60+
print("\033[31mAn unexpected error occurred.\033[0m")

maimai_py/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from importlib.util import find_spec
22

3-
from .maimai import MaimaiAreas, MaimaiClient, MaimaiClientMultithreading, MaimaiItems, MaimaiPlates, MaimaiScores, MaimaiSongs
3+
from .maimai import *
44
from .models import *
55
from .providers import *
66

77
if find_spec("fastapi"):
8-
from .api import MaimaiRoutes
8+
from .api import MaimaiRoutes as MaimaiRoutes

maimai_py/api.py

Lines changed: 199 additions & 43 deletions
Large diffs are not rendered by default.

maimai_py/exceptions.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
from typing import Type
22

3-
from maimai_ffi.exceptions import AimeServerError, ArcadeError, ArcadeIdentifierError, TitleServerBlockedError, TitleServerNetworkError
3+
from maimai_ffi.exceptions import AimeServerError as AimeServerError
4+
from maimai_ffi.exceptions import ArcadeError as ArcadeError
5+
from maimai_ffi.exceptions import ArcadeIdentifierError as ArcadeIdentifierError
6+
from maimai_ffi.exceptions import TitleServerBlockedError as TitleServerBlockedError
7+
from maimai_ffi.exceptions import TitleServerNetworkError as TitleServerNetworkError
48

59
ArcadeError: Type[Exception]
610
AimeServerError: Type[Exception]

0 commit comments

Comments
 (0)