Skip to content

Commit

Permalink
refactor: refactor unnecessary else / elif when if block has a …
Browse files Browse the repository at this point in the history
…`raise` statement

`raise` causes control flow to be disrupted, as it will exit the block.
It is recommended to check other conditions using another `if` statement, and get rid of `else` statements as they are unnecessary.
  • Loading branch information
deepsource-autofix[bot] authored Jan 9, 2024
1 parent eecbb5e commit 237a8cb
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/plugins/nonebot_plugin_heweather/weather_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,10 @@ async def _get_city_id(self, api_type: str = "lookup"):
logger.debug(res)
if res["code"] == "404":
raise CityNotFoundError()
elif res["code"] != "200":
if res["code"] != "200":
raise APIError(f'错误! 错误代码: {res["code"]}{self.__reference}')
else:
self.city_name = res["location"][0]["name"]
return res["location"][0]["id"]
self.city_name = res["location"][0]["name"]
return res["location"][0]["id"]

def _data_validate(self):
if self.now.code != "200" or self.daily.code != "200":
Expand Down

0 comments on commit 237a8cb

Please sign in to comment.