From 6931a22f08c20c8d88dfe00dd5443fe29e091e4a Mon Sep 17 00:00:00 2001
From: Alexandru Fikl <alexfikl@gmail.com>
Date: Mon, 14 Oct 2024 15:05:10 +0300
Subject: [PATCH] fix: new mypy 1.12 errors

---
 arraycontext/container/dataclass.py | 15 ++++++++-------
 arraycontext/container/traversal.py |  4 ++--
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/arraycontext/container/dataclass.py b/arraycontext/container/dataclass.py
index 36c9403..492f0c9 100644
--- a/arraycontext/container/dataclass.py
+++ b/arraycontext/container/dataclass.py
@@ -83,14 +83,15 @@ def dataclass_array_container(cls: type) -> type:
                         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 dataclass_array_container(cls: type) -> type:
             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 a7547df..5f94ad6 100644
--- a/arraycontext/container/traversal.py
+++ b/arraycontext/container/traversal.py
@@ -175,9 +175,9 @@ def _multimap_array_container_impl(
 
                 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)
 
     # }}}
 
-- 
GitLab