Skip to content

Commit

Permalink
Move return statements to else block (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
tr4nt0r authored Sep 19, 2024
1 parent d5424b9 commit d59e31c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions bring_api/bring.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,15 @@ async def load_lists(self) -> BringListResponse:
if key in BringListResponse.__annotations__
},
)
return data
except JSONDecodeError as e:
_LOGGER.debug(
"Exception: Cannot get lists:\n %s", traceback.format_exc()
)
raise BringParseException(
"Loading lists failed during parsing of request response."
) from e
else:
return data
except TimeoutError as e:
_LOGGER.debug("Exception: Cannot get lists:\n %s", traceback.format_exc())
raise BringRequestException(
Expand Down Expand Up @@ -1133,8 +1134,6 @@ async def get_all_user_settings(self) -> BringUserSettingsResponse:
},
)

return data

except JSONDecodeError as e:
_LOGGER.debug(
"Exception: Cannot get user settings for uuid %s:\n%s",
Expand All @@ -1144,6 +1143,8 @@ async def get_all_user_settings(self) -> BringUserSettingsResponse:
raise BringParseException(
"Loading user settings failed during parsing of request response."
) from e
else:
return data
except TimeoutError as e:
_LOGGER.debug(
"Exception: Cannot get user settings for uuid %s:\n%s",
Expand Down Expand Up @@ -1272,14 +1273,15 @@ async def get_user_account(self) -> BringSyncCurrentUserResponse:
if key in BringSyncCurrentUserResponse.__annotations__
},
)
return data
except JSONDecodeError as e:
_LOGGER.debug(
"Exception: Cannot get lists:\n %s", traceback.format_exc()
)
raise BringParseException(
"Loading lists failed during parsing of request response."
) from e
else:
return data
except TimeoutError as e:
_LOGGER.debug(
"Exception: Cannot get current user settings:\n %s",
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ select = [
"T100", # Trace found: {name} used
"T20", # flake8-print
"TID251", # Banned imports
"TRY004", # Prefer TypeError exception for invalid type
"B904", # Use raise from to specify exception cause
"TRY302", # Remove exception handler; error is immediately re-raised
"TRY", # tryceratops
"UP", # pyupgrade
"W", # pycodestyle
]
Expand All @@ -95,6 +94,7 @@ ignore = [
"PLR0915", # Too many statements ({statements} > {max_statements})
"PLR2004", # Magic value used in comparison, consider replacing {value} with a constant variable
"PLW2901", # Outer {outer_kind} variable {name} overwritten by inner {inner_kind} target
"TRY003", # Avoid specifying long messages outside the exception class

# May conflict with the formatter, https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
"W191",
Expand Down

0 comments on commit d59e31c

Please sign in to comment.