Skip to content

Commit

Permalink
use walrus check
Browse files Browse the repository at this point in the history
Signed-off-by: Lucas Gameiro Borges <lucas.borges@canonical.com>
  • Loading branch information
lucasgameiroborges committed Sep 20, 2024
1 parent ca592f7 commit a79a89f
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,7 @@ def get_secret(self, scope: Scopes, key: str) -> Optional[str]:
if scope not in get_args(Scopes):
raise RuntimeError("Unknown secret scope.")

peers = self.model.get_relation(PEER)
if not peers:
if not (peers := self.model.get_relation(PEER)):
return None

secret_key = self._translate_field_to_secret_key(key)
Expand All @@ -356,8 +355,7 @@ def set_secret(self, scope: Scopes, key: str, value: Optional[str]) -> Optional[
if not value:
return self.remove_secret(scope, key)

peers = self.model.get_relation(PEER)
if not peers:
if not (peers := self.model.get_relation(PEER)):
return None

secret_key = self._translate_field_to_secret_key(key)
Expand All @@ -370,8 +368,7 @@ def remove_secret(self, scope: Scopes, key: str) -> None:
if scope not in get_args(Scopes):
raise RuntimeError("Unknown secret scope.")

peers = self.model.get_relation(PEER)
if not peers:
if not (peers := self.model.get_relation(PEER)):
return None

secret_key = self._translate_field_to_secret_key(key)
Expand Down

0 comments on commit a79a89f

Please sign in to comment.