summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2013-02-09 17:01:01 +0100
committerFlorent Xicluna <florent.xicluna@gmail.com>2013-02-09 17:01:01 +0100
commit1c7be5fdc8fce59c40f16670802648e10c76f76f (patch)
treef63d91636b11374db003f30819d93b2fea5262ac
parent2dc5597feb662a916d58370602c345d013dc3482 (diff)
downloadpep8-1c7be5fdc8fce59c40f16670802648e10c76f76f.tar.gz
Allow to register the same checker for different codes
-rwxr-xr-xpep8.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/pep8.py b/pep8.py
index c3adc43..7d31e9d 100755
--- a/pep8.py
+++ b/pep8.py
@@ -1153,15 +1153,20 @@ def register_check(check, codes=None):
"""
Register a new check object.
"""
+ def _add_check(check, kind, codes, args):
+ if check in _checks[kind]:
+ _checks[kind][check][0].extend(codes or [])
+ else:
+ _checks[kind][check] = (codes or [''], args)
if inspect.isfunction(check):
args = inspect.getargspec(check)[0]
if args and args[0] in ('physical_line', 'logical_line'):
if codes is None:
codes = ERRORCODE_REGEX.findall(check.__doc__ or '')
- _checks[args[0]][check] = (codes or [''], args)
+ _add_check(check, args[0], codes, args)
elif inspect.isclass(check):
if inspect.getargspec(check.__init__)[0][:2] == ['self', 'tree']:
- _checks['tree'][check] = (codes or [''], None)
+ _add_check(check, 'tree', codes, None)
def init_checks_registry():