# Path: mugen/lists.py
# class MugenList(list):
#     def __init__(self, items: Optional[List[Any]] = None):
#     def __add__(self, rhs):
#     def __getitem__(self, item):
#     def pretty_repr(self, item_reprs: List[str] = None):
#     def lget(self, attr) -> List[Any]:
#     def flatten(self):
# def flatten(list: List[Any]) -> List[Any]:
# 
# Path: mugen/lists.py
# class MugenList(list):
#     """
#     A subclass of list with extra functionality, used internally
#     """
# 
#     def __init__(self, items: Optional[List[Any]] = None):
#         if items is None:
#             items = []
# 
#         super().__init__(items)
# 
#     def __add__(self, rhs):
#         return type(self)((super().__add__(rhs)))
# 
#     def __getitem__(self, item):
#         result = list.__getitem__(self, item)
#         if isinstance(item, slice):
#             return type(self)(result)
#         else:
#             return result
# 
#     def pretty_repr(self, item_reprs: List[str] = None):
#         if item_reprs is None:
#             item_reprs = [repr(item) for item in self]
# 
#         repr_str = ""
#         for index, element_repr in enumerate(item_reprs):
#             if index != 0:
#                 repr_str += " "
#             repr_str += element_repr
#             if index != len(self) - 1:
#                 repr_str += ", \n"
#         return f"[{repr_str}]"
# 
#     def lget(self, attr) -> List[Any]:
#         """
#         Returns
#         -------
#         A list of values for the attribute, taken from each element in the array
#         """
#         return [getattr(elem, attr) for elem in self]
# 
#     def flatten(self):
#         """
#         Returns
#         -------
#         A new, flattened version of this list.
#         Flattens an arbitrarily nested list of objects
#         """
#         return type(self)(flatten(self))


import pytest
from mugen import lists
from mugen.lists import MugenList



class Dummy(object):
    foo = 1


def get_mugen_list():
    return MugenList([Dummy(), Dummy(), Dummy(), Dummy(), Dummy(), Dummy()])


@pytest.mark.parametrize("list, expected_foo", [(get_mugen_list(), [1, 1, 1, 1, 1, 1])])
def test_lget(list, expected_foo):
    assert list.lget("foo") == expected_foo


@pytest.mark.parametrize(
    "list, expected_l", [([1, [2, 3], [[4, 5], [6, 7]]], [1, 2, 3, 4, 5, 6, 7])]
)
def test_flatten(list, expected_l):
    assert lists.flatten(list) == expected_l


def test_mugen_list__operations_yield_mugen_list():
    assert type(MugenList() + MugenList()) == MugenList

# Path: mugen/lists.py
# class MugenList(list):
#     def __init__(self, items: Optional[List[Any]] = None):
#     def __add__(self, rhs):
#     def __getitem__(self, item):
#     def pretty_repr(self, item_reprs: List[str] = None):
#     def lget(self, attr) -> List[Any]:
#     def flatten(self):
# def flatten(list: List[Any]) -> List[Any]:
# 
# Path: mugen/lists.py
# class MugenList(list):
#     """
#     A subclass of list with extra functionality, used internally
#     """
# 
#     def __init__(self, items: Optional[List[Any]] = None):
#         if items is None:
#             items = []
# 
#         super().__init__(items)
# 
#     def __add__(self, rhs):
#         return type(self)((super().__add__(rhs)))
# 
#     def __getitem__(self, item):
#         result = list.__getitem__(self, item)
#         if isinstance(item, slice):
#             return type(self)(result)
#         else:
#             return result
# 
#     def pretty_repr(self, item_reprs: List[str] = None):
#         if item_reprs is None:
#             item_reprs = [repr(item) for item in self]
# 
#         repr_str = ""
#         for index, element_repr in enumerate(item_reprs):
#             if index != 0:
#                 repr_str += " "
#             repr_str += element_repr
#             if index != len(self) - 1:
#                 repr_str += ", \n"
#         return f"[{repr_str}]"
# 
#     def lget(self, attr) -> List[Any]:
#         """
#         Returns
#         -------
#         A list of values for the attribute, taken from each element in the array
#         """
#         return [getattr(elem, attr) for elem in self]
# 
#     def flatten(self):
#         """
#         Returns
#         -------
#         A new, flattened version of this list.
#         Flattens an arbitrarily nested list of objects
#         """
#         return type(self)(flatten(self))


# Path: tests/unit/test_lists.py
import pytest
from mugen import lists
from mugen.lists import MugenList




class Dummy(object):
    foo = 1


def get_mugen_list():
    return MugenList([Dummy(), Dummy(), Dummy(), Dummy(), Dummy(), Dummy()])


@pytest.mark.parametrize("list, expected_foo", [(get_mugen_list(), [1, 1, 1, 1, 1, 1])])
def test_lget(list, expected_foo):
    assert list.lget("foo") == expected_foo


@pytest.mark.parametrize(
    "list, expected_l", [([1, [2, 3], [[4, 5], [6, 7]]], [1, 2, 3, 4, 5, 6, 7])]
)
def test_flatten(list, expected_l):
    assert lists.flatten(list) == expected_l


def test_mugen_list__operations_yield_mugen_list():
    assert type(MugenList() + MugenList()) == MugenList

    assert type(MugenList()[1:2]) == MugenList