Skip to content

Commit

Permalink
Bear: Check dependency_results kwargs in execute()
Browse files Browse the repository at this point in the history
Add `dependency_results` kwargs checking in `execute()` method.

If `dependency_results` kwargs is defined but there are no
dependency results (usually in Bear that has no dependency)
delete the `dependency_results` kwargs, since most Bears don't
define `dependency_results` kwargs in its `run()` function.

Related to coala#2860
  • Loading branch information
refeed committed Jul 2, 2017
1 parent 78db509 commit d232984
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions coalib/bears/Bear.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,16 @@ def execute(self, *args, debug=False, **kwargs):
name = self.name
try:
self.debug('Running bear {}...'.format(name))

# If `dependency_results` kwargs is defined but there are no
# dependency results (usually in Bear that has no dependency)
# delete the `dependency_results` kwargs, since most Bears don't
# define `dependency_results` kwargs in its `run()` function.
if ('dependency_results' in kwargs and
kwargs['dependency_results'] is None and
not self.BEAR_DEPS):
del kwargs['dependency_results']

# If it's already a list it won't change it
result = self.run_bear_from_section(args, kwargs)
return [] if result is None else list(result)
Expand Down

0 comments on commit d232984

Please sign in to comment.