docstring 使用双引号

This commit is contained in:
qwerdvd 2023-09-18 12:24:06 +08:00
parent 97241e822c
commit ba672f1a16
9 changed files with 62 additions and 63 deletions

View File

@ -1,5 +1,5 @@
'''Mihomo.me api 包装 """Mihomo.me api 包装
''' """
from .models import MihomoData as MihomoData from .models import MihomoData as MihomoData
from .requests import get_char_card_info as requests from .requests import get_char_card_info as requests

View File

@ -63,9 +63,9 @@ class BaseRelicSetSkill:
async def set_skill_ability( async def set_skill_ability(
self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float]
): ):
''' """
战斗加成属性, set_skill_property() 互斥 战斗加成属性, set_skill_property() 互斥
''' """
... ...
def set_skill_property_ability(self): def set_skill_property_ability(self):

View File

@ -34,15 +34,15 @@ class BaseWeapon:
@abstractmethod @abstractmethod
async def weapon_ability(self, base_attr: Dict, attribute_bonus: Dict): async def weapon_ability(self, base_attr: Dict, attribute_bonus: Dict):
''' """
战斗加成属性, weapon_property_ability() 互斥 战斗加成属性, weapon_property_ability() 互斥
''' """
... ...
def weapon_property_ability(self): def weapon_property_ability(self):
''' """
面板加成属性, weapon_ability() 互斥 面板加成属性, weapon_ability() 互斥
''' """
ability_property = EquipmentID2AbilityProperty[str(self.weapon_id)] ability_property = EquipmentID2AbilityProperty[str(self.weapon_id)]
equip_ability_property = ability_property[str(self.weapon_rank)] equip_ability_property = ability_property[str(self.weapon_rank)]
for equip_ability in equip_ability_property: for equip_ability in equip_ability_property:

View File

@ -15,9 +15,9 @@ class Relic101(BaseRelicSetSkill):
async def check( async def check(
self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float]
): ):
''' """
在战斗开始时 在战斗开始时
''' """
logger.info('Relic101 check success') logger.info('Relic101 check success')
return True return True
@ -36,9 +36,9 @@ class Relic102(BaseRelicSetSkill):
async def check( async def check(
self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float]
): ):
''' """
''' """
logger.info('Relic102 check success') logger.info('Relic102 check success')
return True return True
@ -58,9 +58,9 @@ class Relic103(BaseRelicSetSkill):
async def check( async def check(
self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float]
): ):
''' """
战斗中生效:装备者提供的护盾量提高 战斗中生效:装备者提供的护盾量提高
''' """
logger.info('Relic103 check success') logger.info('Relic103 check success')
return True return True
@ -82,9 +82,9 @@ class Relic104(BaseRelicSetSkill):
async def check( async def check(
self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float]
): ):
''' """
装备者施放终结技 装备者施放终结技
''' """
logger.info('Relic104 check success') logger.info('Relic104 check success')
return True return True
@ -106,9 +106,9 @@ class Relic105(BaseRelicSetSkill):
async def check( async def check(
self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float]
): ):
''' """
施放攻击或受到攻击时, 默认叠满 施放攻击或受到攻击时, 默认叠满
''' """
logger.info('Relic105 check success') logger.info('Relic105 check success')
return True return True
@ -130,9 +130,9 @@ class Relic106(BaseRelicSetSkill):
async def check( async def check(
self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float]
): ):
''' """
''' """
logger.info('Relic106 check success') logger.info('Relic106 check success')
return True return True
@ -151,9 +151,9 @@ class Relic107(BaseRelicSetSkill):
async def check( async def check(
self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float]
): ):
''' """
TODO: 检查是否是火属性伤害 TODO: 检查是否是火属性伤害
''' """
logger.info('Relic107 check success') logger.info('Relic107 check success')
return True return True
@ -180,10 +180,10 @@ class Relic108(BaseRelicSetSkill):
async def check( async def check(
self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float]
): ):
''' """
装备者对敌方目标造成伤害 装备者对敌方目标造成伤害
目标拥有量子属性弱点 目标拥有量子属性弱点
''' """
logger.info('Relic108 check success') logger.info('Relic108 check success')
return True return True
@ -206,9 +206,9 @@ class Relic109(BaseRelicSetSkill):
async def check( async def check(
self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float]
): ):
''' """
TODO: 检查是否释放战技 TODO: 检查是否释放战技
''' """
logger.info('Relic109 check success') logger.info('Relic109 check success')
return True return True
@ -231,9 +231,9 @@ class Relic110(BaseRelicSetSkill):
async def check( async def check(
self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float]
): ):
''' """
装备者施放终结技 装备者施放终结技
''' """
logger.info('Relic110 check success') logger.info('Relic110 check success')
return True return True
@ -254,9 +254,9 @@ class Relic111(BaseRelicSetSkill):
async def check( async def check(
self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float]
): ):
''' """
装备者击破敌方目标弱点 装备者击破敌方目标弱点
''' """
logger.info('Relic111 check success') logger.info('Relic111 check success')
return True return True
@ -277,10 +277,10 @@ class Relic112(BaseRelicSetSkill):
async def check( async def check(
self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float]
): ):
''' """
装备者对陷入负面效果的敌方目标造成伤害 装备者对陷入负面效果的敌方目标造成伤害
对陷入禁锢状态的敌方目标造成伤害 对陷入禁锢状态的敌方目标造成伤害
''' """
logger.info('Relic111 check success') logger.info('Relic111 check success')
return True return True
@ -310,9 +310,9 @@ class Relic113(BaseRelicSetSkill):
async def check( async def check(
self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float]
): ):
''' """
当装备者受到攻击或被我方目标消耗生命值后, 暴击率提高8%, 持续2回合, 该效果最多叠加2层 当装备者受到攻击或被我方目标消耗生命值后, 暴击率提高8%, 持续2回合, 该效果最多叠加2层
''' """
logger.info('Relic113 check success') logger.info('Relic113 check success')
return True return True
@ -336,9 +336,9 @@ class Relic114(BaseRelicSetSkill):
async def check( async def check(
self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float]
): ):
''' """
当装备者对我方目标施放终结技时, 我方全体速度提高12%, 持续1回合, 该效果无法叠加 当装备者对我方目标施放终结技时, 我方全体速度提高12%, 持续1回合, 该效果无法叠加
''' """
logger.info('Relic114 check success') logger.info('Relic114 check success')
return True return True
@ -360,9 +360,9 @@ class Relic301(BaseRelicSetSkill):
async def check( async def check(
self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float]
): ):
''' """
装备者的速度大于等于120 装备者的速度大于等于120
''' """
merged_attr = await merge_attribute(base_attr, attribute_bonus) merged_attr = await merge_attribute(base_attr, attribute_bonus)
if merged_attr['speed'] >= 120: if merged_attr['speed'] >= 120:
logger.info('Relic306 check success') logger.info('Relic306 check success')
@ -387,9 +387,9 @@ class Relic302(BaseRelicSetSkill):
async def check( async def check(
self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float]
): ):
''' """
装备者的速度大于等于120 装备者的速度大于等于120
''' """
merged_attr = await merge_attribute(base_attr, attribute_bonus) merged_attr = await merge_attribute(base_attr, attribute_bonus)
if merged_attr['speed'] >= 120: if merged_attr['speed'] >= 120:
logger.info('Relic306 check success') logger.info('Relic306 check success')
@ -438,9 +438,9 @@ class Relic304(BaseRelicSetSkill):
async def check( async def check(
self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float]
): ):
''' """
备者的效果命中大于等于50% 备者的效果命中大于等于50%
''' """
merged_attr = await merge_attribute(base_attr, attribute_bonus) merged_attr = await merge_attribute(base_attr, attribute_bonus)
if merged_attr['StatusResistanceBase'] >= 0.5000000004656613: if merged_attr['StatusResistanceBase'] >= 0.5000000004656613:
logger.info('Relic306 check success') logger.info('Relic306 check success')
@ -465,9 +465,9 @@ class Relic305(BaseRelicSetSkill):
async def check( async def check(
self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float]
): ):
''' """
装备者的暴击伤害大于等于120% 装备者的暴击伤害大于等于120%
''' """
merged_attr = await merge_attribute(base_attr, attribute_bonus) merged_attr = await merge_attribute(base_attr, attribute_bonus)
if merged_attr['CriticalDamageBase'] >= 1.2000000001862645: if merged_attr['CriticalDamageBase'] >= 1.2000000001862645:
logger.info('Relic306 check success') logger.info('Relic306 check success')
@ -492,9 +492,9 @@ class Relic306(BaseRelicSetSkill):
async def check( async def check(
self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float]
): ):
''' """
装备者当前暴击率大于等于50% 装备者当前暴击率大于等于50%
''' """
merged_attr = await merge_attribute(base_attr, attribute_bonus) merged_attr = await merge_attribute(base_attr, attribute_bonus)
if merged_attr['CriticalChanceBase'] >= 0.5: if merged_attr['CriticalChanceBase'] >= 0.5:
logger.info('Relic306 check success') logger.info('Relic306 check success')
@ -519,9 +519,9 @@ class Relic307(BaseRelicSetSkill):
async def check( async def check(
self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float]
): ):
''' """
装备者的速度大于等于145 装备者的速度大于等于145
''' """
merged_attr = await merge_attribute(base_attr, attribute_bonus) merged_attr = await merge_attribute(base_attr, attribute_bonus)
if merged_attr['speed'] >= 145: if merged_attr['speed'] >= 145:
logger.info('Relic306 check success') logger.info('Relic306 check success')
@ -548,9 +548,9 @@ class Relic308(BaseRelicSetSkill):
async def check( async def check(
self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float]
): ):
''' """
装备者的速度大于等于120 装备者的速度大于等于120
''' """
merged_attr = await merge_attribute(base_attr, attribute_bonus) merged_attr = await merge_attribute(base_attr, attribute_bonus)
if merged_attr['speed'] >= 120: if merged_attr['speed'] >= 120:
logger.info('Relic306 check success') logger.info('Relic306 check success')
@ -572,9 +572,9 @@ class Relic309(BaseRelicSetSkill):
async def check( async def check(
self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float]
): ):
''' """
当装备者的当前暴击率大于等于70%, 普攻和战技造成的伤害提高20% 当装备者的当前暴击率大于等于70%, 普攻和战技造成的伤害提高20%
''' """
merged_attr = await merge_attribute(base_attr, attribute_bonus) merged_attr = await merge_attribute(base_attr, attribute_bonus)
if merged_attr['CriticalChanceBase'] >= 0.7: if merged_attr['CriticalChanceBase'] >= 0.7:
logger.info('Relic309 check success') logger.info('Relic309 check success')
@ -599,9 +599,9 @@ class Relic310(BaseRelicSetSkill):
async def check( async def check(
self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float] self, base_attr: Dict[str, float], attribute_bonus: Dict[str, float]
): ):
''' """
当装备者的效果抵抗大于等于30%, 我方全体暴击伤害提高10% 当装备者的效果抵抗大于等于30%, 我方全体暴击伤害提高10%
''' """
merged_attr = await merge_attribute(base_attr, attribute_bonus) merged_attr = await merge_attribute(base_attr, attribute_bonus)
if merged_attr['StatusResistanceBase'] >= 0.3: if merged_attr['StatusResistanceBase'] >= 0.3:
logger.info('Relic310 check success') logger.info('Relic310 check success')

View File

@ -165,10 +165,10 @@ async def get_part_uid(part: str, uid: str):
async def get_fake_char_str(char_name: str) -> Tuple[str, Optional[int]]: async def get_fake_char_str(char_name: str) -> Tuple[str, Optional[int]]:
''' """
获取一个角色信息 获取一个角色信息
''' """
talent_num = None talent_num = None
if '' in char_name and char_name[0] in CHAR_TO_INT: if '' in char_name and char_name[0] in CHAR_TO_INT:
talent_num = CHAR_TO_INT[char_name[0]] talent_num = CHAR_TO_INT[char_name[0]]

View File

@ -34,7 +34,7 @@ from .cal_value import cal_relic_main_affix, cal_relic_sub_affix
async def api_to_dict( async def api_to_dict(
sr_uid: str, sr_data: Optional[MihomoData] = None sr_uid: str, sr_data: Optional[MihomoData] = None
) -> Union[List[Dict], str]: ) -> Union[List[Dict], str]:
''' """
:说明: :说明:
访问Mihomo.me API并转换为StarRailUID的数据Json 访问Mihomo.me API并转换为StarRailUID的数据Json
:参数: :参数:
@ -42,7 +42,7 @@ async def api_to_dict(
* ``sr_data: Optional[Dict] = None``: 来自Mihomo.me的dict, 可留空 * ``sr_data: Optional[Dict] = None``: 来自Mihomo.me的dict, 可留空
:返回: :返回:
* ``刷新完成提示语: str``: 包含刷新成功的角色列表 * ``刷新完成提示语: str``: 包含刷新成功的角色列表
''' """
if '未找到绑定的UID' in sr_uid: if '未找到绑定的UID' in sr_uid:
return UID_HINT return UID_HINT
if not sr_data: if not sr_data:

View File

@ -30,7 +30,7 @@ async def convert_img(img: Path, is_base64: bool = False) -> str:
async def convert_img( async def convert_img(
img: Union[Image.Image, str, Path, bytes], is_base64: bool = False img: Union[Image.Image, str, Path, bytes], is_base64: bool = False
) -> Union[str, bytes]: ) -> Union[str, bytes]:
''' """
:说明: :说明:
将PIL.Image对象转换为bytes或者base64格式 将PIL.Image对象转换为bytes或者base64格式
:参数: :参数:
@ -38,7 +38,7 @@ async def convert_img(
* is_base64 (bool): 是否转换为base64格式, 不填默认转为bytes * is_base64 (bool): 是否转换为base64格式, 不填默认转为bytes
:返回: :返回:
* res: bytes对象或base64编码图片 * res: bytes对象或base64编码图片
''' """
if isinstance(img, Image.Image): if isinstance(img, Image.Image):
img = img.convert('RGB') img = img.convert('RGB')
result_buffer = BytesIO() result_buffer = BytesIO()

View File

@ -20,7 +20,7 @@ async def download(
resource_type: str, resource_type: str,
name: str, name: str,
) -> Optional[Tuple[str, str, str]]: ) -> Optional[Tuple[str, str, str]]:
''' """
:说明: :说明:
下载URL保存入目录 下载URL保存入目录
:参数: :参数:
@ -36,7 +36,7 @@ async def download(
url: `str` url: `str`
resource_type: `str` resource_type: `str`
name: `str` name: `str`
''' """
async with ClientSession() as sess: async with ClientSession() as sess:
return await download_file(url, res_type, resource_type, name, sess) return await download_file(url, res_type, resource_type, name, sess)

View File

@ -102,4 +102,3 @@ target-version = "py38"
[tool.ruff.flake8-quotes] [tool.ruff.flake8-quotes]
inline-quotes = "single" inline-quotes = "single"
multiline-quotes = "single" multiline-quotes = "single"
docstring-quotes = "single"