Coverage for src/castep_linter/fortran/fortran_statement.py: 69%

1""""Module with base class for Fortran code parser classes"""

2 from typing import ClassVar, List

3

4 from castep_linter.fortran.fortran_node import Fortran, FortranNode

5 from castep_linter.fortran.node_type_err import WrongNodeError

6

7

8 class FortranStatementParser:

9 """Base class for fortran statement parsers"""

10

11 ALLOWED_NODES: ClassVar[List[Fortran]] = []

12

13 def __init__(self, node: FortranNode):

14 if not any(node.is_type(ftype) for ftype in self.ALLOWED_NODES): 14 ↛ exit, 14 ↛ 152 missed branches: 1) line 14 didn't finish the generator expression on line 14, 2) line 14 didn't jump to line 15, because the condition on line 14 was never true

15 err = f"{node.type} not in {self.ALLOWED_NODES}"

16 raise WrongNodeError(err)

17

18 self.node = node