• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Hekxsler / pudding / 20777776429

07 Jan 2026 09:22AM UTC coverage: 88.574% (+0.3%) from 88.305%
20777776429

Pull #1

github

web-flow
[tests]: add coverage for out.replace
Pull Request #1: Increase performance with custom node class

1155 of 1304 relevant lines covered (88.57%)

0.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.36
pudding/processor/triggers.py
1
"""Module defining Trigger and TriggerQueue class."""
2

3
from enum import Enum
1✔
4
from re import Pattern
1✔
5
from typing import TypeVar
1✔
6

7
from ..tokens.token import Token
1✔
8

9
Timing = Enum("Timing", "AFTER BEFORE ON_ADD")
1✔
10
_D = TypeVar("_D")
1✔
11

12

13
class Trigger:
1✔
14
    """Base trigger class."""
15

16
    def __init__(self, match: Pattern[str], token: Token) -> None:
1✔
17
        """Trigger class.
18

19
        :param match: Pattern to match before executing.
20
        :param token: Token to execute on match.
21
        """
22
        self.match = match
1✔
23
        self.token = token
1✔
24

25
    def __repr__(self) -> str:
26
        """Return string representation of this object."""
27
        cls = self.__class__.__name__
28
        return f"<{cls} match=/{self.match.pattern}/ token={self.token}>"
29

30

31
class TriggerQueue(dict[Timing, list[Trigger]]):
1✔
32
    """Queue for triggers.
33

34
    :var triggers: Dictionary where the key is a timing and
35
        the value a list of triggers.
36
    """
37

38
    def __init__(self) -> None:
1✔
39
        self.triggers: dict[Timing, list[Trigger]] = {}
1✔
40
        return super().__init__()
1✔
41

42
    def add_trigger(self, timing: Timing, trigger: Trigger) -> None:
1✔
43
        """Add a trigger to the queue.
44

45
        :param timing: Timing of the queue.
46
        :param trigger: Trigger to add.
47
        """
48
        triggers = self.get(timing, [])
1✔
49
        triggers.append(trigger)
1✔
50
        self[timing] = triggers
1✔
51

52
    def clear_triggers(self, timing: Timing | None = None) -> None:
1✔
53
        """Clear a trigger queue.
54

55
        :param timing: Timing of a queue to clear or none to clear all.
56
        """
57
        if timing:
×
58
            self[timing] = []
×
59
        else:
60
            self.triggers = {}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc