Browse files

Patch pylint error messages (#554)

Patch pylint error messages
  • Loading branch information...
dhslim authored and david-yz-liu committed Oct 18, 2018
1 parent 466e72f commit 96bbc97ceeaba15f4bb913b6df2fd61b94bdf57d
Showing with 32 additions and 0 deletions.
  1. +2 −0 python_ta/patches/
  2. +30 −0 python_ta/patches/
@@ -3,6 +3,7 @@
from .checkers import patch_checkers
from .type import patch_type_inference_transform
from .messages import patch_messages, patch_linter_transform
from .error_messages import patch_error_messages
def patch_all():
@@ -11,3 +12,4 @@ def patch_all():
@@ -0,0 +1,30 @@
"""Patch pylint error messages."""
from importlib import import_module
# global
patch_data = {
{'W0107': 'Unnecessary pass statement (you should remove this)'}
# We are assuming only the first elements of the tuple values in <msgs> are being patched.
def patch_error_messages():
"""Patch <msgs> in pylint checkers to make them more helpful for python_ta clients."""
for file_name, file_data in patch_data.items():
for checker_name, checker_data in file_data.items():
# only access the specific variable being changed
checker = getattr(import_module(file_name), checker_name)
if hasattr(checker, 'msgs'):
for error_id, new_msg in checker_data.items():
lst_msg = list(checker.msgs[error_id])
# first element of the tuple value changed
lst_msg[0] = new_msg
checker.msgs[error_id] = tuple(lst_msg)
print('no msgs attribute!')
# TODO: patch more pylint error messages

0 comments on commit 96bbc97

Please sign in to comment.