Use default flake8 config
diff --git a/pre_commit_hooks/check_builtin_literals.py b/pre_commit_hooks/check_builtin_literals.py
index 874c68c..4ddaa8c 100644
--- a/pre_commit_hooks/check_builtin_literals.py
+++ b/pre_commit_hooks/check_builtin_literals.py
@@ -21,22 +21,23 @@
}
-BuiltinTypeCall = collections.namedtuple('BuiltinTypeCall', ['name', 'line', 'column'])
+Call = collections.namedtuple('Call', ['name', 'line', 'column'])
-class BuiltinTypeVisitor(ast.NodeVisitor):
+class Visitor(ast.NodeVisitor):
def __init__(self, ignore=None, allow_dict_kwargs=True):
# type: (Optional[Sequence[str]], bool) -> None
- self.builtin_type_calls = [] # type: List[BuiltinTypeCall]
+ self.builtin_type_calls = [] # type: List[Call]
self.ignore = set(ignore) if ignore else set()
self.allow_dict_kwargs = allow_dict_kwargs
def _check_dict_call(self, node): # type: (ast.Call) -> bool
-
- return self.allow_dict_kwargs and (getattr(node, 'kwargs', None) or getattr(node, 'keywords', None))
+ return (
+ self.allow_dict_kwargs and
+ (getattr(node, 'kwargs', None) or getattr(node, 'keywords', None))
+ )
def visit_Call(self, node): # type: (ast.Call) -> None
-
if not isinstance(node.func, ast.Name):
# Ignore functions that are object attributes (`foo.bar()`).
# Assume that if the user calls `builtins.list()`, they know what
@@ -49,15 +50,15 @@
elif node.args:
return
self.builtin_type_calls.append(
- BuiltinTypeCall(node.func.id, node.lineno, node.col_offset),
+ Call(node.func.id, node.lineno, node.col_offset),
)
-def check_file_for_builtin_type_constructors(filename, ignore=None, allow_dict_kwargs=True):
- # type: (str, Optional[Sequence[str]], bool) -> List[BuiltinTypeCall]
+def check_file(filename, ignore=None, allow_dict_kwargs=True):
+ # type: (str, Optional[Sequence[str]], bool) -> List[Call]
with open(filename, 'rb') as f:
tree = ast.parse(f.read(), filename=filename)
- visitor = BuiltinTypeVisitor(ignore=ignore, allow_dict_kwargs=allow_dict_kwargs)
+ visitor = Visitor(ignore=ignore, allow_dict_kwargs=allow_dict_kwargs)
visitor.visit(tree)
return visitor.builtin_type_calls
@@ -73,14 +74,17 @@
mutex = parser.add_mutually_exclusive_group(required=False)
mutex.add_argument('--allow-dict-kwargs', action='store_true')
- mutex.add_argument('--no-allow-dict-kwargs', dest='allow_dict_kwargs', action='store_false')
+ mutex.add_argument(
+ '--no-allow-dict-kwargs',
+ dest='allow_dict_kwargs', action='store_false',
+ )
mutex.set_defaults(allow_dict_kwargs=True)
args = parser.parse_args(argv)
rc = 0
for filename in args.filenames:
- calls = check_file_for_builtin_type_constructors(
+ calls = check_file(
filename,
ignore=args.ignore,
allow_dict_kwargs=args.allow_dict_kwargs,
@@ -89,7 +93,8 @@
rc = rc or 1
for call in calls:
print(
- '{filename}:{call.line}:{call.column} - Replace {call.name}() with {replacement}'.format(
+ '{filename}:{call.line}:{call.column}: '
+ 'replace {call.name}() with {replacement}'.format(
filename=filename,
call=call,
replacement=BUILTIN_TYPES[call.name],