Skip to content

Commit

Permalink
Remove assert statement from non-test files
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
deepsource-autofix[bot] authored and rht committed May 18, 2022
1 parent e45929b commit feb72b1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion examples/color_patches/color_patches/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def color_patch_draw(cell):
:return: the portrayal dictionary.
"""
assert cell is not None
if cell is None:
raise AssertionError
portrayal = {"Shape": "rect", "w": 1, "h": 1, "Filled": "true", "Layer": 0}
portrayal["x"] = cell.get_row()
portrayal["y"] = cell.get_col()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ def portrayCell(cell):
:param cell: the cell in the simulation
:return: the portrayal dictionary.
"""
assert cell is not None
if cell is None:
raise AssertionError
return {
"Shape": "rect",
"w": 1,
Expand Down
3 changes: 2 additions & 1 deletion examples/hex_snowflake/hex_snowflake/portrayal.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ def portrayCell(cell):
:param cell: the cell in the simulation
:return: the portrayal dictionary.
"""
assert cell is not None
if cell is None:
raise AssertionError
return {
"Shape": "hex",
"r": 1,
Expand Down
3 changes: 2 additions & 1 deletion examples/pd_grid/pd_grid/portrayal.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ def portrayPDAgent(agent):
:param agent: the agent in the simulation
:return: the portrayal dictionary
"""
assert agent is not None
if agent is None:
raise AssertionError
return {
"Shape": "rect",
"w": 1,
Expand Down

0 comments on commit feb72b1

Please sign in to comment.