Coverage for phml\nodes\parent.py: 38%

16 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2022-11-30 09:38 -0600

1from __future__ import annotations 

2 

3from typing import TYPE_CHECKING, Optional 

4 

5from .node import Node 

6 

7if TYPE_CHECKING: 

8 from .comment import Comment 

9 from .doctype import DocType 

10 from .element import Element 

11 from .position import Position 

12 from .text import Text 

13 

14 

15class Parent(Node): 

16 """Parent (UnistParent) represents a node in hast containing other nodes (said to be children). 

17 

18 Its content is limited to only other hast content. 

19 """ 

20 

21 def __init__(self, position: Optional[Position] = None, children: Optional[list] = None): 

22 super().__init__(position) 

23 

24 if children is not None: 

25 for child in children: 

26 child.parent = self 

27 

28 self.children: list[Element | DocType | Comment | Text] = children or []