Skip to content

Commit

Permalink
fix: new mypy 1.12 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfikl authored and inducer committed Oct 14, 2024
1 parent 5891804 commit 6931a22
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
15 changes: 8 additions & 7 deletions arraycontext/container/dataclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions arraycontext/container/traversal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

# }}}

Expand Down

0 comments on commit 6931a22

Please sign in to comment.