Skip to content

Commit

Permalink
Merge pull request #318 from GillesPy2/isinstance_fix2
Browse files Browse the repository at this point in the history
removed uses of isinstance with module objects
  • Loading branch information
briandrawert authored Apr 13, 2020
2 parents 6728d37 + 8875706 commit e1f5fb1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions gillespy2/core/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def __init__(self, name="", delay = None, assignments = [], priority="0",
'name must be a valid string')

# Trigger
if isinstance(trigger, EventTrigger):
if hasattr(trigger, 'expression'):
self.trigger = trigger
else:
raise EventError(
Expand All @@ -154,12 +154,12 @@ def __init__(self, name="", delay = None, assignments = [], priority="0",
# Assignments
if isinstance(assignments, list):
for assign in assignments:
if isinstance(assign, EventAssignment):
if hasattr(assign, 'variable'):
self.assignments.append(assign)
else:
raise EventError('assignment list contains an item '
'is not an EventAssignment.')
elif isinstance(assignments, EventAssignment):
elif hasattr(assignments, 'variable'):
self.assignments.append(assignments)
else:
raise EventError(
Expand Down Expand Up @@ -190,11 +190,11 @@ def add_assignment(self, assignment):
The event or list of events to be added to this event.
"""

if isinstance(assignment, EventAssignment):
if hasattr(assignment, 'variable'):
self.assignments.append(assignment)
elif isinstance(assignment, list):
for assign in assignment:
if isinstance(assign, EventAssignment):
if hasattr(assign, 'variable'):
self.assignments.append(assign)
else:
raise EventError('add_assignment failed to add EventAssignment. '
Expand Down

0 comments on commit e1f5fb1

Please sign in to comment.