Skip to content

Commit

Permalink
chore: 更新依赖库 ruff 到 v0.9.0,并应用最新 linting 与 formatting 规则
Browse files Browse the repository at this point in the history
  • Loading branch information
FHU-yezi committed Jan 16, 2025
1 parent 577d736 commit 40faa2e
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 34 deletions.
4 changes: 2 additions & 2 deletions backend/api/v1/jpep/ftn_macket.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ async def get_price_history_handler(
type_: Annotated[
Literal["buy", "sell"], Parameter(description="交易单类型", query="type")
],
range: Annotated[ # noqa: A002
range: Annotated[
Literal["24h", "7d", "15d", "30d"], Parameter(description="时间范围")
],
resolution: Annotated[Literal["5m", "1h", "1d"], Parameter(description="统计粒度")],
Expand Down Expand Up @@ -156,7 +156,7 @@ async def get_amount_history_handler(
type_: Annotated[
Literal["buy", "sell"], Parameter(description="交易单类型", query="type")
],
range: Annotated[ # noqa: A002
range: Annotated[
Literal["24h", "7d", "15d", "30d"], Parameter(description="时间范围")
],
resolution: Annotated[Literal["5m", "1h", "1d"], Parameter(description="统计粒度")],
Expand Down
4 changes: 2 additions & 2 deletions backend/api/v1/lottery.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class GetSummaryResponse(Struct, **RESPONSE_STRUCT_CONFIG):
},
)
async def get_summary_handler(
range: Annotated[ # noqa: A002
range: Annotated[
Literal["1d", "7d", "30d", "all"], Parameter(description="时间范围")
],
) -> Response:
Expand Down Expand Up @@ -214,7 +214,7 @@ class GetRewardWinsHistoryResponse(Struct, **RESPONSE_STRUCT_CONFIG):
},
)
async def get_reward_wins_history_handler(
range: Annotated[Literal["1d", "30d", "60d"], Parameter(description="时间范围")], # noqa: A002
range: Annotated[Literal["1d", "30d", "60d"], Parameter(description="时间范围")],
resolution: Annotated[Literal["1h", "1d"], Parameter(description="统计粒度")],
) -> Response:
history = await LotteryWinRecord.get_wins_history(
Expand Down
10 changes: 5 additions & 5 deletions backend/models/jpep/ftn_macket_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class FTNMacketRecord(Table, frozen=True):
minimum_trade_amount: PositiveInt

@classmethod
async def get_current_price(cls, type: Literal["BUY", "SELL"]) -> float: # noqa: A002
async def get_current_price(cls, type: Literal["BUY", "SELL"]) -> float:
async with jpep_pool.get_conn() as conn:
if type == "BUY":
cursor = await conn.execute(
Expand All @@ -38,7 +38,7 @@ async def get_current_price(cls, type: Literal["BUY", "SELL"]) -> float: # noqa
return (await cursor.fetchone())[0] # type: ignore

@classmethod
async def get_current_amount(cls, type: Literal["BUY", "SELL"]) -> int: # noqa: A002
async def get_current_amount(cls, type: Literal["BUY", "SELL"]) -> int:
async with jpep_pool.get_conn() as conn:
cursor = await conn.execute(
"SELECT SUM(remaining_amount) FROM ftn_macket_records "
Expand All @@ -53,7 +53,7 @@ async def get_current_amount(cls, type: Literal["BUY", "SELL"]) -> int: # noqa:
@classmethod
async def get_current_amount_distribution(
cls,
type: Literal["BUY", "SELL"], # noqa: A002
type: Literal["BUY", "SELL"],
limit: int,
) -> dict[float, int]:
async with jpep_pool.get_conn() as conn:
Expand All @@ -75,7 +75,7 @@ async def get_current_amount_distribution(
@classmethod
async def get_price_history(
cls,
type: Literal["BUY", "SELL"], # noqa: A002
type: Literal["BUY", "SELL"],
start_time: datetime,
resolution: Literal["max", "hour", "day"],
) -> dict[datetime, float]:
Expand Down Expand Up @@ -130,7 +130,7 @@ async def get_price_history(
@classmethod
async def get_amount_history(
cls,
type: Literal["BUY", "SELL"], # noqa: A002
type: Literal["BUY", "SELL"],
start_time: datetime,
resolution: Literal["max", "hour", "day"],
) -> dict[datetime, int]:
Expand Down
6 changes: 4 additions & 2 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies = [
]

[tool.uv]
dev-dependencies = ["pyright>=1.1.0", "ruff>=0.8.0", "watchfiles>=0.24.0"]
dev-dependencies = ["pyright>=1.1.0", "ruff>=0.9.0", "watchfiles>=0.24.0"]

[tool.ruff]
target-version = "py39"
Expand Down Expand Up @@ -55,11 +55,13 @@ lint.select = [
"W",
]
lint.ignore = [
"ISC001",
"A005",
"PERF203",
"RUF001",
"RUF002",
"RUF003",
"S311",
"TRY003",
]

lint.flake8-builtins.builtins-ignorelist = ["id", "range", "type"]
2 changes: 1 addition & 1 deletion backend/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ python-dateutil==2.9.0.post0
pyyaml==6.0.2
rich==13.9.4
rich-click==1.8.5
ruff==0.8.1
ruff==0.9.2
six==1.16.0
sniffio==1.3.1
sshared==0.19.1
Expand Down
44 changes: 22 additions & 22 deletions backend/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 40faa2e

Please sign in to comment.