Skip to content

Commit

Permalink
✨ 在命名中明确表示cond_func意图
Browse files Browse the repository at this point in the history
  • Loading branch information
AzideCupric committed Mar 29, 2024
1 parent 20c3cbd commit 2d28ac2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions nonebot_bison/platform/ceobecanteen/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,24 +76,24 @@ async def get_by_nickname(self, nickname: str) -> CeobeTarget | None:
如果在缓存中找不到,会刷新缓存
"""

def cond_func(target: CeobeTarget):
def select_by_nickname(target: CeobeTarget):
return target.nickname == nickname

if target := self.select_one(cond_func):
if target := self.select_one(select_by_nickname):
return target
await self.refresh_data_sources()
return self.select_one(cond_func)
return self.select_one(select_by_nickname)

async def get_by_source(self, source: CeobeSource) -> CeobeTarget | None:
"""根据source获取数据源
如果在缓存中找不到,会刷新缓存
"""

def cond_func(target: CeobeTarget):
def select_by_source(target: CeobeTarget):
return target.db_unique_key == source.data and target.datasource == source.type

if target := self.select_one(cond_func):
if target := self.select_one(select_by_source):
return target
await self.refresh_data_sources()
return self.select_one(cond_func)
return self.select_one(select_by_source)

0 comments on commit 2d28ac2

Please sign in to comment.