<commit_before>"""Module providing few iterable types with str() respecting PEP 3140.

FIXME: Guard against possible cycles in graphs of references.
"""

from collections import deque


class List(list):
    """A list with str support."""

    def __str__(self):
        """Return comma+space separated str of items in square brackets."""
        if not self:
            return "[]"
        substr_list = []
        for item in self:
            substr_list.append(", ")
            substr_list.append(str(item))
        substr_list.append("]")
        substr_list[0] = "["
        return "".join(substr_list)


class Tuple(tuple):
    """A tuple with str support."""

    def __str__(self):
        """Return comma+space separated str of items in round brackets."""
        if not self:
            return "()"
        substr_list = []
        for item in self:
            substr_list.append(", ")
            substr_list.append(str(item))
        substr_list.append(")")
        substr_list[0] = "("
        return "".join(substr_list)


class Dict(dict):
    """A dict with str support."""

    def __str__(self):
        """Return comma+space separated str of items in curly brackets."""
        if not self:
            return "{}"
        substr_list = []
        for key, value in self.items():
            substr_list.append(", ")
            substr_list.append(str(key))
            substr_list.append(": ")
            substr_list.append(str(value))
        substr_list.append("}")
        substr_list[0] = "{"
        return "".join(substr_list)


class Deque(deque):
    """A deque with str support."""

    def __str__(self):
        """Return str of List corresponding to self."""
        # TODO: What about "Deque([1, 2, ...])"?
        return str(List(self))<commit_msg>Simplify pep_3140.py<commit_after>"""Module providing few iterable types with str() respecting PEP 3140.

FIXME: Guard against possible cycles in graphs of references.
"""

from collections import deque


class List(list):
    """A list with str support."""

    def __str__(self):
        """Return comma+space separated str of items in square brackets."""
        return "[" + ", ".join([str(item) for item in self]) + "]"


class Tuple(tuple):
    """A tuple with str support."""

    def __str__(self):
        """Return comma+space separated str of items in round brackets."""
        return "(" + ", ".join([str(item) for item in self]) + ")"


class Dict(dict):
    """A dict with str support."""

    def __str__(self):
        """Return comma+space separated str of items in curly brackets."""
        return "{" + ", ".join([str(key) + ": " + str(value) for key, value in self.items()]) + "}"


class Deque(deque):
    """A deque with str support."""

    def __str__(self):
        """Return str of List corresponding to self."""
        # TODO: What about "Deque([1, 2, ...])"?
        return str(List(self))
{'fraction_non_alphanumeric': 0.1451169188445667, 'fraction_numerical': 0.006533700137551582, 'mean_word_length': 2.438534278959811, 'pattern_counts': {'":': 2, '<': 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': '4684701', 'n_tokens_mistral': 866, 'n_tokens_neox': 812, 'n_words': 268}