Skip to content
Browse files
coalib/abstractions: Add
Introduce a virtual base class for linters and use it to
improve the check inside `LocalBearTestHelper`.
i.e. Instead of checking `hasattr(cls, 'process_output')`, an
`isinstance(cls, LinterClass)` is safer and easier to understand.

Related to #4594
  • Loading branch information
yash-nisar committed Aug 2, 2017
1 parent 0415ef1 commit 9f279e47d2be8790d47dae3ec321503682f79095
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
@@ -8,6 +8,7 @@
from subprocess import check_call, CalledProcessError, DEVNULL
from types import MappingProxyType

from coalib.bearlib.abstractions.LinterClass import LinterClass
from coalib.bears.LocalBear import LocalBear
from coalib.bears.GlobalBear import GlobalBear
from coala_utils.ContextManagers import make_temp
@@ -737,6 +738,7 @@ def create_arguments(config_file):
result_klass = type(klass.__name__, (klass, LinterBaseClass), {
'__module__': klass.__module__})
result_klass.__doc__ = klass.__doc__ or ''
return result_klass

@@ -835,6 +837,11 @@ def linter(executable: str,
and ``use_stderr=False`` raises a ``ValueError``. By default ``use_stdout``
is ``True`` and ``use_stderr`` is ``False``.
Every ``linter`` is also a subclass of the ``LinterClass`` class.
>>> issubclass(XLintBear, LinterClass)
Bear description shall be provided at class level.
If you document your additional parameters inside ``create_arguments``,
@@ -0,0 +1,7 @@
from abc import ABCMeta

class LinterClass(metaclass=ABCMeta):
Every ``linter`` is also a subclass of the ``LinterClass`` class.

0 comments on commit 9f279e4

Please sign in to comment.