diff --git a/arraycontext/container/dataclass.py b/arraycontext/container/dataclass.py index 36c94030..492f0c92 100644 --- a/arraycontext/container/dataclass.py +++ b/arraycontext/container/dataclass.py @@ -83,14 +83,15 @@ def is_array_field(f: Field) -> bool: f"Field '{f.name}' union contains non-array container " "arguments. All arguments must be array containers.") + if isinstance(f.type, str): + raise TypeError( + f"String annotation on field '{f.name}' not supported. " + "(this may be due to 'from __future__ import annotations')") + if __debug__: if not f.init: raise ValueError( - f"'init=False' field not allowed: '{f.name}'") - - if isinstance(f.type, str): - raise TypeError( - f"string annotation on field '{f.name}' not supported") + f"Field with 'init=False' not allowed: '{f.name}'") # NOTE: # * `_BaseGenericAlias` catches `List`, `Tuple`, etc. @@ -102,12 +103,12 @@ def is_array_field(f: Field) -> bool: if isinstance(f.type, (_BaseGenericAlias, _SpecialForm)): # NOTE: anything except a Union is not allowed raise TypeError( - f"typing annotation not supported on field '{f.name}': " + f"Typing annotation not supported on field '{f.name}': " f"'{f.type!r}'") if not isinstance(f.type, type): raise TypeError( - f"field '{f.name}' not an instance of 'type': " + f"Field '{f.name}' not an instance of 'type': " f"'{f.type!r}'") return is_array_type(f.type) diff --git a/arraycontext/container/traversal.py b/arraycontext/container/traversal.py index a7547df2..5f94ad63 100644 --- a/arraycontext/container/traversal.py +++ b/arraycontext/container/traversal.py @@ -175,9 +175,9 @@ def rec(*_args: Any) -> Any: new_args[i] = subary - result.append((key, frec(*new_args))) # type: ignore[operator] + result.append((key, frec(*new_args))) - return process_container(template_ary, result) # type: ignore[operator] + return process_container(template_ary, result) # }}}