diff options
author | Florent Xicluna <florent.xicluna@gmail.com> | 2013-02-09 17:01:01 +0100 |
---|---|---|
committer | Florent Xicluna <florent.xicluna@gmail.com> | 2013-02-09 17:01:01 +0100 |
commit | 1c7be5fdc8fce59c40f16670802648e10c76f76f (patch) | |
tree | f63d91636b11374db003f30819d93b2fea5262ac | |
parent | 2dc5597feb662a916d58370602c345d013dc3482 (diff) | |
download | pep8-1c7be5fdc8fce59c40f16670802648e10c76f76f.tar.gz |
Allow to register the same checker for different codes
-rwxr-xr-x | pep8.py | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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(): |