11.08., 9:00 - 11:00: Due to updates GitLab will be unavailable for some minutes between 09:00 and 11:00.

Commit bc4584d6 authored by Eckhart Arnold's avatar Eckhart Arnold

- mypy type errors repiared

parent c4a03af4
......@@ -752,7 +752,7 @@ class EBNFCompiler(Compiler):
# prepare and add skip-rules
for symbol, skip in self.directives.skip.items():
skip_rules = [] # type: List[Tuple[ReprType, ReprType]]
skip_rules = [] # type: List[ReprType]
for search in skip:
if isinstance(search, unrepr) and search.s.isidentifier():
try:
......@@ -1031,7 +1031,7 @@ class EBNFCompiler(Compiler):
return self.non_terminal(node, 'Alternative')
def _error_customization(self, node) -> Tuple[Tuple[Node], List[str]]:
def _error_customization(self, node) -> Tuple[Tuple[Node, ...], List[str]]:
mandatory_marker = []
filtered_children = [] # type: List[Node]
for nd in node.children:
......
......@@ -1351,7 +1351,11 @@ MessagesType = List[Tuple[Union[str, Any], str]]
NO_MANDATORY = 1000
def mandatory_violation(grammar, text_, expected, err_msgs, reloc):
def mandatory_violation(grammar: Grammar,
text_: StringView,
expected: str,
err_msgs: MessagesType,
reloc: int) -> Tuple[Error, Node, StringView]:
i = reloc if reloc >= 0 else 0
location = grammar.document_length__ - len(text_)
err_node = Node(None, text_[:i]).init_pos(location)
......@@ -1426,7 +1430,7 @@ class Series(NaryOperator):
assert 0 <= mandatory < length or mandatory == NO_MANDATORY
self.mandatory = mandatory # type: int
self.err_msgs = err_msgs # type: Series.MessagesType
self.err_msgs = err_msgs # type: MessagesType
self.skip = skip # type: ResumeList
def __deepcopy__(self, memo):
......@@ -1635,7 +1639,7 @@ class AllOf(NaryOperator):
assert 0 <= mandatory < self.num_parsers or mandatory == NO_MANDATORY
self.mandatory = mandatory # type: int
self.err_msgs = err_msgs # type: Series.MessagesType
self.err_msgs = err_msgs # type: MessagesType
self.skip = skip # type: ResumeList
def __deepcopy__(self, memo):
......
......@@ -348,8 +348,8 @@ def grammar_unit(test_unit, parser_factory, transformer_factory, report=True, ve
# case 2: mandatory lookahead failure at end of text
or (len(raw_errors) == 1
and raw_errors[-1].code == Error.MANDATORY_CONTINUATION_AT_EOF)
and any(isinstance(parser, Lookahead)
for parser in parser.history__[-1].call_stack))
and any(isinstance(p, Lookahead)
for p in parser.history__[-1].call_stack))
for parser_name, tests in test_unit.items():
assert parser_name, "Missing parser name in test %s!" % unit_name
......@@ -376,6 +376,7 @@ def grammar_unit(test_unit, parser_factory, transformer_factory, report=True, ve
# run match tests
for test_name, test_code in tests.get('match', dict()).items():
errflag = 0
if verbose:
infostr = ' match-test "' + test_name + '" ... '
errflag = len(errata)
......@@ -424,6 +425,7 @@ def grammar_unit(test_unit, parser_factory, transformer_factory, report=True, ve
# run fail tests
for test_name, test_code in tests.get('fail', dict()).items():
errflag = 0
if verbose:
infostr = ' fail-test "' + test_name + '" ... '
errflag = len(errata)
......
......@@ -165,6 +165,8 @@ def transformation_factory(t1=None, t2=None, t3=None, t4=None, t5=None):
# raise TypeError("Generic Type %s not permitted\n in transformation_factory "
# "decorator. Use the equivalent non-generic type instead!"
# % str(t))
if isinstance(t, str): # ensure compatibility with python versions
t = eval(t) # with alternative type handling.
if isgenerictype(t):
raise TypeError("Generic Type %s not permitted\n in transformation_factory "
"decorator. Use the equivalent non-generic type instead!"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment