<commit_before>"""
implementation of a stack
"""
from linked_list import LinkedList


class Stack(object):

    def __init__(self, iterable=None):
        if type(iterable) in [list, tuple, str]:
            self._container = LinkedList(iterable=iterable)

        elif type(iterable) is None:
            self._container = LinkedList()

        else:
            raise TypeError('You need to use an iterable or no arguments.')


    def push(self, value):
        """
        uses the linked list as the underlying data structure
        """
        self._container.push(value)

    def pop(self):
        """
        uses the linked list as the underlying data structure,
        """
        return self._container.pop()

    def __len__(self):
        """
        allows for the built-in len func
        """
        return self._container.length


def main(): # pragma: no cover
    """
    main function
    """
    a_stack = Stack([1, 2, 3, 4, 5, 'A', 'B'])
    print(dir(a_stack))



if __name__ == '__main__': # pragma: no cover
    main()
<commit_msg>refactor condition check in stack initializer<commit_after>"""
implementation of a stack
"""
from linked_list import LinkedList


class Stack(object):

    def __init__(self, iterable=None):
        if type(iterable) in [list, tuple, str]:
            self._container = LinkedList(iterable=iterable)

        elif iterable is None:
            self._container = LinkedList()

        else:
            raise TypeError('You need to use an iterable or no arguments.')

    def push(self, value):
        """
        uses the linked list as the underlying data structure
        """
        self._container.push(value)

    def pop(self):
        """
        uses the linked list as the underlying data structure,
        """
        return self._container.pop()

    def __len__(self):
        """
        allows for the built-in len func
        """
        return self._container.length


def main():  # pragma: no cover
    """
    main function
    """
    a_stack = Stack([1, 2, 3, 4, 5, 'A', 'B'])
    print(dir(a_stack))


if __name__ == '__main__':  # pragma: no cover
    main()

{'fraction_non_alphanumeric': 0.11183597390493942, 'fraction_numerical': 0.004659832246039142, 'mean_word_length': 2.1949404761904763, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5343106', 'n_tokens_mistral': 631, 'n_tokens_neox': 600, 'n_words': 201}