summaryrefslogtreecommitdiff
path: root/pylint/extensions/bad_builtin.py
diff options
context:
space:
mode:
Diffstat (limited to 'pylint/extensions/bad_builtin.py')
-rw-r--r--pylint/extensions/bad_builtin.py54
1 files changed, 30 insertions, 24 deletions
diff --git a/pylint/extensions/bad_builtin.py b/pylint/extensions/bad_builtin.py
index 9876922eb..2609d3168 100644
--- a/pylint/extensions/bad_builtin.py
+++ b/pylint/extensions/bad_builtin.py
@@ -12,37 +12,43 @@ from pylint.checkers.utils import check_messages
from pylint.interfaces import IAstroidChecker
-BAD_FUNCTIONS = ['map', 'filter']
+BAD_FUNCTIONS = ["map", "filter"]
if sys.version_info < (3, 0):
- BAD_FUNCTIONS.append('input')
+ BAD_FUNCTIONS.append("input")
# Some hints regarding the use of bad builtins.
-BUILTIN_HINTS = {
- 'map': 'Using a list comprehension can be clearer.',
-}
-BUILTIN_HINTS['filter'] = BUILTIN_HINTS['map']
+BUILTIN_HINTS = {"map": "Using a list comprehension can be clearer."}
+BUILTIN_HINTS["filter"] = BUILTIN_HINTS["map"]
class BadBuiltinChecker(BaseChecker):
- __implements__ = (IAstroidChecker, )
- name = 'deprecated_builtins'
- msgs = {'W0141': ('Used builtin function %s',
- 'bad-builtin',
- 'Used when a black listed builtin function is used (see the '
- 'bad-function option). Usual black listed functions are the ones '
- 'like map, or filter , where Python offers now some cleaner '
- 'alternative like list comprehension.'),
- }
+ __implements__ = (IAstroidChecker,)
+ name = "deprecated_builtins"
+ msgs = {
+ "W0141": (
+ "Used builtin function %s",
+ "bad-builtin",
+ "Used when a black listed builtin function is used (see the "
+ "bad-function option). Usual black listed functions are the ones "
+ "like map, or filter , where Python offers now some cleaner "
+ "alternative like list comprehension.",
+ )
+ }
- options = (('bad-functions',
- {'default' : BAD_FUNCTIONS,
- 'type' :'csv', 'metavar' : '<builtin function names>',
- 'help' : 'List of builtins function names that should not be '
- 'used, separated by a comma'}
- ),
- )
+ options = (
+ (
+ "bad-functions",
+ {
+ "default": BAD_FUNCTIONS,
+ "type": "csv",
+ "metavar": "<builtin function names>",
+ "help": "List of builtins function names that should not be "
+ "used, separated by a comma",
+ },
+ ),
+ )
- @check_messages('bad-builtin')
+ @check_messages("bad-builtin")
def visit_call(self, node):
if isinstance(node.func, astroid.Name):
name = node.func.name
@@ -55,7 +61,7 @@ class BadBuiltinChecker(BaseChecker):
args = "%r. %s" % (name, hint)
else:
args = repr(name)
- self.add_message('bad-builtin', node=node, args=args)
+ self.add_message("bad-builtin", node=node, args=args)
def register(linter):