Path 1: 86 calls (0.74)

TagDict def (14) TagTuple def (14) TagBytes def (14) TagMarkup def (14) TagUUID def (14) TagDateTime def (14) test_custom_tag..TagFoo def (1) ...

False (86)

None (86)

1def register(
2        self,
3        tag_class: type[JSONTag],
4        force: bool = False,
5        index: int | None = None,
6    ) -> None:
7        """Register a new tag with this serializer.
8
9        :param tag_class: tag class to register. Will be instantiated with this
10            serializer instance.
11        :param force: overwrite an existing tag. If false (default), a
12            :exc:`KeyError` is raised.
13        :param index: index to insert the new tag in the tag order. Useful when
14            the new tag is a special case of an existing tag. If ``None``
15            (default), the tag is appended to the end of the order.
16
17        :raise KeyError: if the tag key is already registered and ``force`` is
18            not true.
19        """
20        tag = tag_class(self)
21        key = tag.key
22
23        if key is not None:
24            if not force and key in self.tags:
25                raise KeyError(f"Tag '{key}' is already registered.")
26
27            self.tags[key] = tag
28
29        if index is None:
30            self.order.append(tag)
31        else:
32            self.order.insert(index, tag)
            

Path 2: 28 calls (0.24)

PassDict def (14) PassList def (14)

False (28)

None (28)

1def register(
2        self,
3        tag_class: type[JSONTag],
4        force: bool = False,
5        index: int | None = None,
6    ) -> None:
7        """Register a new tag with this serializer.
8
9        :param tag_class: tag class to register. Will be instantiated with this
10            serializer instance.
11        :param force: overwrite an existing tag. If false (default), a
12            :exc:`KeyError` is raised.
13        :param index: index to insert the new tag in the tag order. Useful when
14            the new tag is a special case of an existing tag. If ``None``
15            (default), the tag is appended to the end of the order.
16
17        :raise KeyError: if the tag key is already registered and ``force`` is
18            not true.
19        """
20        tag = tag_class(self)
21        key = tag.key
22
23        if key is not None:
24            if not force and key in self.tags:
25                raise KeyError(f"Tag '{key}' is already registered.")
26
27            self.tags[key] = tag
28
29        if index is None:
30            self.order.append(tag)
31        else:
32            self.order.insert(index, tag)
            

Path 3: 2 calls (0.02)

test_duplicate_tag..TagDict def (1) test_tag_order..Tag1 def (1)

True (1) False (1)

0 (1) -1 (1)

1def register(
2        self,
3        tag_class: type[JSONTag],
4        force: bool = False,
5        index: int | None = None,
6    ) -> None:
7        """Register a new tag with this serializer.
8
9        :param tag_class: tag class to register. Will be instantiated with this
10            serializer instance.
11        :param force: overwrite an existing tag. If false (default), a
12            :exc:`KeyError` is raised.
13        :param index: index to insert the new tag in the tag order. Useful when
14            the new tag is a special case of an existing tag. If ``None``
15            (default), the tag is appended to the end of the order.
16
17        :raise KeyError: if the tag key is already registered and ``force`` is
18            not true.
19        """
20        tag = tag_class(self)
21        key = tag.key
22
23        if key is not None:
24            if not force and key in self.tags:
25                raise KeyError(f"Tag '{key}' is already registered.")
26
27            self.tags[key] = tag
28
29        if index is None:
30            self.order.append(tag)
31        else:
32            self.order.insert(index, tag)
            

Path 4: 1 calls (0.01)

test_duplicate_tag..TagDict def (1)

False (1)

None (1)

KeyError (1)

1def register(
2        self,
3        tag_class: type[JSONTag],
4        force: bool = False,
5        index: int | None = None,
6    ) -> None:
7        """Register a new tag with this serializer.
8
9        :param tag_class: tag class to register. Will be instantiated with this
10            serializer instance.
11        :param force: overwrite an existing tag. If false (default), a
12            :exc:`KeyError` is raised.
13        :param index: index to insert the new tag in the tag order. Useful when
14            the new tag is a special case of an existing tag. If ``None``
15            (default), the tag is appended to the end of the order.
16
17        :raise KeyError: if the tag key is already registered and ``force`` is
18            not true.
19        """
20        tag = tag_class(self)
21        key = tag.key
22
23        if key is not None:
24            if not force and key in self.tags:
25                raise KeyError(f"Tag '{key}' is already registered.")
26
27            self.tags[key] = tag
28
29        if index is None:
30            self.order.append(tag)
31        else:
32            self.order.insert(index, tag)