Skip to content

Commit feb72b1

Browse files
deepsource-autofix[bot]rht
authored andcommitted
Remove assert statement from non-test files
Usage of assert statement in application logic is discouraged. assert is removed with compiling to optimised byte code (python -o producing *.pyo files). Consider raising an exception instead. Ideally, assert statement should be used only in tests.
1 parent e45929b commit feb72b1

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

examples/color_patches/color_patches/server.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ def color_patch_draw(cell):
4646
:return: the portrayal dictionary.
4747
4848
"""
49-
assert cell is not None
49+
if cell is None:
50+
raise AssertionError
5051
portrayal = {"Shape": "rect", "w": 1, "h": 1, "Filled": "true", "Layer": 0}
5152
portrayal["x"] = cell.get_row()
5253
portrayal["y"] = cell.get_col()

examples/conways_game_of_life/conways_game_of_life/portrayal.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ def portrayCell(cell):
55
:param cell: the cell in the simulation
66
:return: the portrayal dictionary.
77
"""
8-
assert cell is not None
8+
if cell is None:
9+
raise AssertionError
910
return {
1011
"Shape": "rect",
1112
"w": 1,

examples/hex_snowflake/hex_snowflake/portrayal.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ def portrayCell(cell):
55
:param cell: the cell in the simulation
66
:return: the portrayal dictionary.
77
"""
8-
assert cell is not None
8+
if cell is None:
9+
raise AssertionError
910
return {
1011
"Shape": "hex",
1112
"r": 1,

examples/pd_grid/pd_grid/portrayal.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ def portrayPDAgent(agent):
55
:param agent: the agent in the simulation
66
:return: the portrayal dictionary
77
"""
8-
assert agent is not None
8+
if agent is None:
9+
raise AssertionError
910
return {
1011
"Shape": "rect",
1112
"w": 1,

0 commit comments

Comments
 (0)