Skip to content

Commit d7c8f41

Browse files
refactor: change methods not using its bound instance to staticmethods
The method doesn't use its bound instance. Decorate this method with `@staticmethod` decorator, so that Python does not have to instantiate a bound method for every instance of this class thereby saving memory and computation. Read more about staticmethods [here](https://docs.python.org/3/library/functions.html#staticmethod).
1 parent 78b74ab commit d7c8f41

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

nonebot_plugin_genshin_cos/hoyospider.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ async def async_name(self, params: dict, is_good: bool = False):
143143
response = await client.get(self.api, params=params, headers=self.headers)
144144
return self.get_rsp_name(response, is_good)
145145

146-
def handle_response(self, response: Response, is_good: bool = False) -> list:
146+
@staticmethod
147+
def handle_response(response: Response, is_good: bool = False) -> list:
147148
"""
148149
处理响应
149150
@@ -161,7 +162,8 @@ def handle_response(self, response: Response, is_good: bool = False) -> list:
161162

162163
return [image for post in posts for image in post["post"]["images"]]
163164

164-
def get_rsp_name(self, response: Response, is_good: bool = False) -> list:
165+
@staticmethod
166+
def get_rsp_name(response: Response, is_good: bool = False) -> list:
165167
"""
166168
获取响应的帖子名称
167169

0 commit comments

Comments
 (0)