# Path: pre_commit_hooks/check_builtin_literals.py
# class Call(NamedTuple):
#     name: str
#     line: int
#     column: int
# 
# Path: pre_commit_hooks/check_builtin_literals.py
# def main(argv: Sequence[str] | None = None) -> int:
#     parser = argparse.ArgumentParser()
#     parser.add_argument('filenames', nargs='*')
#     parser.add_argument('--ignore', type=parse_ignore, default=set())
# 
#     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.set_defaults(allow_dict_kwargs=True)
# 
#     args = parser.parse_args(argv)
# 
#     rc = 0
#     for filename in args.filenames:
#         calls = check_file(
#             filename,
#             ignore=args.ignore,
#             allow_dict_kwargs=args.allow_dict_kwargs,
#         )
#         if calls:
#             rc = rc or 1
#         for call in calls:
#             print(
#                 f'{filename}:{call.line}:{call.column}: '
#                 f'replace {call.name}() with {BUILTIN_TYPES[call.name]}',
#             )
#     return rc
# 
# Path: pre_commit_hooks/check_builtin_literals.py
# class Visitor(ast.NodeVisitor):
#     def __init__(
#             self,
#             ignore: Sequence[str] | None = None,
#             allow_dict_kwargs: bool = True,
#     ) -> None:
#         self.builtin_type_calls: list[Call] = []
#         self.ignore = set(ignore) if ignore else set()
#         self.allow_dict_kwargs = allow_dict_kwargs
# 
#     def _check_dict_call(self, node: ast.Call) -> bool:
#         return self.allow_dict_kwargs and bool(node.keywords)
# 
#     def visit_Call(self, node: 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
#             # they're doing.
#             return
#         if node.func.id not in set(BUILTIN_TYPES).difference(self.ignore):
#             return
#         if node.func.id == 'dict' and self._check_dict_call(node):
#             return
#         elif node.args:
#             return
#         self.builtin_type_calls.append(
#             Call(node.func.id, node.lineno, node.col_offset),
#         )


import ast
import pytest
from pre_commit_hooks.check_builtin_literals import Call
from pre_commit_hooks.check_builtin_literals import main
from pre_commit_hooks.check_builtin_literals import Visitor
d2 = builtins.dict()
f2 = builtins.float()
i2 = builtins.int()
l2 = builtins.list()
s2 = builtins.str()
t2 = builtins.tuple()
'''
BUILTIN_LITERALS = '''\
c1 = 0j
d1 = {}
f1 = 0.0
i1 = 0
l1 = []
s1 = ''
t1 = ()
'''


@pytest.fixture
def visitor():
    return Visitor()


@pytest.mark.parametrize(
    ('expression', 'calls'),
    [
        # see #285
        ('x[0]()', []),
        # complex
        ('0j', []),

# Path: pre_commit_hooks/check_builtin_literals.py
# class Call(NamedTuple):
#     name: str
#     line: int
#     column: int
# 
# Path: pre_commit_hooks/check_builtin_literals.py
# def main(argv: Sequence[str] | None = None) -> int:
#     parser = argparse.ArgumentParser()
#     parser.add_argument('filenames', nargs='*')
#     parser.add_argument('--ignore', type=parse_ignore, default=set())
# 
#     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.set_defaults(allow_dict_kwargs=True)
# 
#     args = parser.parse_args(argv)
# 
#     rc = 0
#     for filename in args.filenames:
#         calls = check_file(
#             filename,
#             ignore=args.ignore,
#             allow_dict_kwargs=args.allow_dict_kwargs,
#         )
#         if calls:
#             rc = rc or 1
#         for call in calls:
#             print(
#                 f'{filename}:{call.line}:{call.column}: '
#                 f'replace {call.name}() with {BUILTIN_TYPES[call.name]}',
#             )
#     return rc
# 
# Path: pre_commit_hooks/check_builtin_literals.py
# class Visitor(ast.NodeVisitor):
#     def __init__(
#             self,
#             ignore: Sequence[str] | None = None,
#             allow_dict_kwargs: bool = True,
#     ) -> None:
#         self.builtin_type_calls: list[Call] = []
#         self.ignore = set(ignore) if ignore else set()
#         self.allow_dict_kwargs = allow_dict_kwargs
# 
#     def _check_dict_call(self, node: ast.Call) -> bool:
#         return self.allow_dict_kwargs and bool(node.keywords)
# 
#     def visit_Call(self, node: 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
#             # they're doing.
#             return
#         if node.func.id not in set(BUILTIN_TYPES).difference(self.ignore):
#             return
#         if node.func.id == 'dict' and self._check_dict_call(node):
#             return
#         elif node.args:
#             return
#         self.builtin_type_calls.append(
#             Call(node.func.id, node.lineno, node.col_offset),
#         )


# Path: tests/check_builtin_literals_test.py
import ast
import pytest
from pre_commit_hooks.check_builtin_literals import Call
from pre_commit_hooks.check_builtin_literals import main
from pre_commit_hooks.check_builtin_literals import Visitor

d2 = builtins.dict()
f2 = builtins.float()
i2 = builtins.int()
l2 = builtins.list()
s2 = builtins.str()
t2 = builtins.tuple()
'''
BUILTIN_LITERALS = '''\
c1 = 0j
d1 = {}
f1 = 0.0
i1 = 0
l1 = []
s1 = ''
t1 = ()
'''


@pytest.fixture
def visitor():
    return Visitor()


@pytest.mark.parametrize(
    ('expression', 'calls'),
    [
        # see #285
        ('x[0]()', []),
        # complex
        ('0j', []),

        ('complex()', [Call('complex', 1, 0)]),