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

Commit a1d64ccd authored by eckhart's avatar eckhart
Browse files

- transformation factory decorator broken in Python 3.7 :-(

parent b2ce311f
...@@ -35,7 +35,7 @@ from DHParser.error import Error ...@@ -35,7 +35,7 @@ from DHParser.error import Error
from DHParser.syntaxtree import Node, WHITESPACE_PTYPE, TOKEN_PTYPE, MockParser, ZOMBIE_NODE from DHParser.syntaxtree import Node, WHITESPACE_PTYPE, TOKEN_PTYPE, MockParser, ZOMBIE_NODE
from DHParser.toolkit import expand_table, smart_list, re, typing from DHParser.toolkit import expand_table, smart_list, re, typing
from typing import AbstractSet, Any, ByteString, Callable, cast, Container, Dict, \ from typing import AbstractSet, Any, ByteString, Callable, cast, Container, Dict, \
Tuple, List, Sequence, Union, Text, GenericMeta Tuple, List, Sequence, Union, Text, Generic
__all__ = ('TransformationDict', __all__ = ('TransformationDict',
'TransformationProc', 'TransformationProc',
...@@ -154,11 +154,15 @@ def transformation_factory(t1=None, t2=None, t3=None, t4=None, t5=None): ...@@ -154,11 +154,15 @@ def transformation_factory(t1=None, t2=None, t3=None, t4=None, t5=None):
"""Raises an error if type `t` is a generic type or could be mistaken """Raises an error if type `t` is a generic type or could be mistaken
for the type of the canonical first parameter "List[Node] of for the type of the canonical first parameter "List[Node] of
transformation functions. Returns `t`.""" transformation functions. Returns `t`."""
if isinstance(t, GenericMeta): # if isinstance(t, GenericMeta):
# raise TypeError("Generic Type %s not permitted\n in transformation_factory "
# "decorator. Use the equivalent non-generic type instead!"
# % str(t))
if hasattr(t, '__parameters__') and t.__parameters:
raise TypeError("Generic Type %s not permitted\n in transformation_factory " raise TypeError("Generic Type %s not permitted\n in transformation_factory "
"decorator. Use the equivalent non-generic type instead!" "decorator. Use the equivalent non-generic type instead!"
% str(t)) % str(t))
if issubclass(List[Node], t): if t == List[Node]: # issubclass(List[Node], t)
raise TypeError("Sequence type %s not permitted\nin transformation_factory " raise TypeError("Sequence type %s not permitted\nin transformation_factory "
"decorator, because it could be mistaken for a base class " "decorator, because it could be mistaken for a base class "
"of List[Node]\nwhich is the type of the canonical first " "of List[Node]\nwhich is the type of the canonical first "
......
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