<commit_before>from abc import ABC, abstractmethod
from collections import defaultdict
from threading import Event, Lock, Thread
from typing import Dict, Iterable, Iterator, List, Set, Tuple, Type, TypeVar

from eventsourcing.application import Application, NotificationLog, Section
from eventsourcing.domain import Aggregate, AggregateEvent
from eventsourcing.persistence import (
    Mapper,
    Notification,
    ProcessRecorder,
    Tracking,
)
from eventsourcing.utils import get_topic, resolve_topic


class ProcessEvent:
    """
    Keeps together a :class:`~eventsourcing.persistence.Tracking`
    object, which represents the position of a domain event notification
    in the notification log of a particular application, and the
    new domain events that result from processing that notification.
    """

    def __init__(self, tracking: Tracking):
        """
        Initalises the process event with the given tracking object.
        """
        self.tracking = tracking
        self.events: List[AggregateEvent] = []

    def save(self, *aggregates: Aggregate) -> None:
        """
        Collects pending domain events from the given aggregate.<commit_msg>Adjusted the type annotation for the 'tracking' arg of ProcessEvent class.<commit_after>from abc import ABC, abstractmethod
from collections import defaultdict
from threading import Event, Lock, Thread
from typing import (
    Dict,
    Iterable,
    Iterator,
    List,
    Optional,
    Set,
    Tuple,
    Type,
    TypeVar,
)

from eventsourcing.application import Application, NotificationLog, Section
from eventsourcing.domain import Aggregate, AggregateEvent
from eventsourcing.persistence import (
    Mapper,
    Notification,
    ProcessRecorder,
    Tracking,
)
from eventsourcing.utils import get_topic, resolve_topic


class ProcessEvent:
    """
    Keeps together a :class:`~eventsourcing.persistence.Tracking`
    object, which represents the position of a domain event notification
    in the notification log of a particular application, and the
    new domain events that result from processing that notification.
    """

    def __init__(self, tracking: Optional[Tracking] = None):
        """
        Initalises the process event with the given tracking object.
        """
        self.tracking = tracking
        self.events: List[AggregateEvent] = []

    def save(self, *aggregates: Aggregate) -> None:
        """
        Collects pending domain events from the given aggregate.
{'fraction_non_alphanumeric': 0.06610237807335752, 'fraction_numerical': 0.0, 'mean_word_length': 3.570902394106814, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1168990', 'n_tokens_mistral': 635, 'n_tokens_neox': 611, 'n_words': 239}