• 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

84.62
pudding/datatypes/util.py
1
"""Utility functions for data types."""
2

3
import re
1✔
4

5
from .data import Data
1✔
6
from .or_ import Or
1✔
7
from .regex import Regex
1✔
8
from .string import String
1✔
9
from .varname import Varname
1✔
10

11
DATATYPES: list[type[Data]] = [String, Regex, Varname, Or]
1✔
12

13

14
def string_to_datatype(string: str, line: int) -> Data:
1✔
15
    """Convert a given string to a DataType.
16

17
    :param string: Value to convert.
18
    :param line: Line number of this value.
19
    :returns: The given value as a DataType.
20
    :raises TypeError: If there is no matching DataType.
21
    """
22
    for cls in DATATYPES:
1✔
23
        if re.fullmatch(cls.regex, string):
1✔
24
            return cls(line, string)
1✔
25
    msg = f"Unknown type of value {repr(string)} in line {line}"
×
26
    raise TypeError(f"{msg}, must be a string, regex or varname.")
×
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