Skip to content

Commit

Permalink
Simplify accept_tuple_argument decorator in space.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Tortar committed Nov 19, 2022
1 parent bd26c2f commit fd0051f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mesa/space.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ def accept_tuple_argument(wrapped_function: F) -> F:
to also handle a single position, by automatically wrapping tuple in
single-item list rather than forcing user to do it."""

def wrapper(*args: Any) -> Any:
if isinstance(args[1], tuple) and len(args[1]) == 2:
return wrapped_function(args[0], [args[1]])
def wrapper(grid_instance, positions) -> Any:
if isinstance(positions, tuple) and len(positions) == 2:
return wrapped_function(grid_instance, [positions])
else:
return wrapped_function(*args)
return wrapped_function(grid_instance, positions)

return cast(F, wrapper)

Expand Down

0 comments on commit fd0051f

Please sign in to comment.