Skip to content

Commit beee667

Browse files
committed
Use assert instead of raise AssertionError
Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 046b9d8 commit beee667

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/frequenz/sdk/microgrid/connection_manager.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,12 @@ async def initialize(server_url: str) -> None:
172172
where the port should be an int between `0` and `65535` (defaulting to
173173
`9090`) and ssl should be a boolean (defaulting to false). For example:
174174
`grpc://localhost:1090?ssl=true`.
175-
176-
Raises:
177-
AssertionError: If method was called more then once.
178175
"""
179176
# From Doc: pylint just try to discourage this usage.
180177
# That doesn't mean you cannot use it.
181178
global _CONNECTION_MANAGER # pylint: disable=global-statement
182179

183-
if _CONNECTION_MANAGER is not None:
184-
raise AssertionError("MicrogridApi was already initialized.")
180+
assert _CONNECTION_MANAGER is None, "MicrogridApi was already initialized."
185181

186182
_logger.info("Connecting to microgrid at %s", server_url)
187183

@@ -190,8 +186,7 @@ async def initialize(server_url: str) -> None:
190186

191187
# Check again that _MICROGRID_API is None in case somebody had the great idea of
192188
# calling initialize() twice and in parallel.
193-
if _CONNECTION_MANAGER is not None:
194-
raise AssertionError("MicrogridApi was already initialized.")
189+
assert _CONNECTION_MANAGER is None, "MicrogridApi was already initialized."
195190

196191
_CONNECTION_MANAGER = microgrid_api
197192

0 commit comments

Comments
 (0)