• 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

72.22
pudding/tokens/functions/function.py
1
"""Module defining functions."""
2

3
from ...datatypes import Data, String
1✔
4
from ..token import Token
1✔
5

6
OPTIONAL_STRING = rf"(?:\, *({String.regex}))?"
1✔
7

8

9
class Function(Token):
1✔
10
    """Base class for a function.
11

12
    :var min_args: Minimum amount of arguments.
13
    :var max_args: Maximum amount of arguments.
14
    """
15

16
    min_args = 0
1✔
17
    max_args = 0
1✔
18

19
    def __init__(self, lineno: int, name: str, values: tuple[Data, ...]) -> None:
1✔
20
        """Init for Function class.
21

22
        :param lineno: Line number in .pud file.
23
        :param name: Name of the function.
24
        :param values: Values of the arguments.
25
        :raises SyntaxError:
26
        """
27
        if self.min_args <= len(values) <= self.max_args:
1✔
28
            return super().__init__(lineno, name, values)
1✔
29
        err_msg = f"Expected {self.min_args} but got {len(values)}"
×
30
        if len(values) < self.min_args:
×
31
            raise SyntaxError(f"Missing arguments in line {lineno}. {err_msg}")
×
32
        raise SyntaxError(f"Too many arguments in line {lineno}. {err_msg}")
×
33

34
    def get_string(self, index: int) -> String:
1✔
35
        """Get String object in values.
36

37
        :param index: Index of the object in values.
38
        :returns: The String object at the given index.
39
        :raises TypeError: If object at given index is not of type String.
40
        """
41
        value = self.values[index]
1✔
42
        if isinstance(value, String):
1✔
43
            return value
1✔
44
        raise TypeError(f"Value {repr(value)} is not a string. (line {self.lineno})")
×
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