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

earwig / mwparserfromhell / 15962349696

30 Jun 2025 02:19AM UTC coverage: 98.662% (-0.2%) from 98.886%
15962349696

push

github

earwig
Fix coverage action and add pre-commit hook action

3097 of 3139 relevant lines covered (98.66%)

9.86 hits per line

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

87.5
/src/mwparserfromhell/nodes/_base.py
1
# Copyright (C) 2012-2025 Ben Kurtovic <ben.kurtovic@gmail.com>
2
#
3
# Permission is hereby granted, free of charge, to any person obtaining a copy
4
# of this software and associated documentation files (the "Software"), to deal
5
# in the Software without restriction, including without limitation the rights
6
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
# copies of the Software, and to permit persons to whom the Software is
8
# furnished to do so, subject to the following conditions:
9
#
10
# The above copyright notice and this permission notice shall be included in
11
# all copies or substantial portions of the Software.
12
#
13
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
# SOFTWARE.
20

21
from __future__ import annotations
10✔
22

23
from collections.abc import Generator
10✔
24
from typing import TYPE_CHECKING, Any, Callable
10✔
25

26
from ..string_mixin import StringMixIn
10✔
27

28
if TYPE_CHECKING:
10✔
29
    from ..wikicode import Wikicode
×
30

31
__all__ = ["Node"]
10✔
32

33

34
class Node(StringMixIn):
10✔
35
    """Represents the base Node type, demonstrating the methods to override.
36

37
    :meth:`__str__` must be overridden. It should return a ``str``
38
    representation of the node. If the node contains :class:`.Wikicode`
39
    objects inside of it, :meth:`__children__` should be a generator that
40
    iterates over them. If the node is printable (shown when the page is
41
    rendered), :meth:`__strip__` should return its printable version,
42
    stripping out any formatting marks. It does not have to return a string,
43
    but something that can be converted to a string with ``str()``. Finally,
44
    :meth:`__showtree__` can be overridden to build a nice tree representation
45
    of the node, if desired, for :meth:`~.Wikicode.get_tree`.
46
    """
47

48
    def __str__(self) -> str:
10✔
49
        raise NotImplementedError()
×
50

51
    def __children__(self) -> Generator[Wikicode, None, None]:
10✔
52
        return
10✔
53
        # pylint: disable=unreachable
54
        yield  # pragma: no cover (this is a generator that yields nothing)
55

56
    def __strip__(self, **kwargs: Any) -> str | None:
10✔
57
        return None
10✔
58

59
    def __showtree__(
10✔
60
        self,
61
        write: Callable[[str], None],
62
        get: Callable[[Wikicode], None],
63
        mark: Callable[[], None],
64
    ) -> None:
65
        write(str(self))
10✔
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