From 7859e9714bad9d17c34854bc0da21186286ef55d Mon Sep 17 00:00:00 2001 From: Matthias Diener Date: Sat, 14 Oct 2023 15:43:55 -0500 Subject: [PATCH] work around mypy/attrs issue --- pytato/stringifier.py | 7 +++++-- pytato/visualization/dot.py | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pytato/stringifier.py b/pytato/stringifier.py index 8aac8d3..269c9a5 100644 --- a/pytato/stringifier.py +++ b/pytato/stringifier.py @@ -95,7 +95,9 @@ class Reprifier(Mapper): if depth > self.truncation_depth: return self.truncation_string - fields = tuple(field.name for field in attrs.fields(type(expr))) + # type-ignore-reason: https://github.com/python/mypy/issues/16254 + fields = tuple(field.name + for field in attrs.fields(type(expr))) # type: ignore[misc] if expr.ndim <= 1: # prettify: if ndim <=1 'expr.axes' would be trivial, @@ -153,7 +155,8 @@ class Reprifier(Mapper): return (f"{type(expr).__name__}(" + ", ".join(f"{field.name}={_get_field_val(field.name)}" - for field in attrs.fields(type(expr))) + # type-ignore-reason: https://github.com/python/mypy/issues/16254 + for field in attrs.fields(type(expr))) # type: ignore[misc] + ")") def map_loopy_call(self, expr: LoopyCall, depth: int) -> str: diff --git a/pytato/visualization/dot.py b/pytato/visualization/dot.py index d84b3aa..32a2ae5 100644 --- a/pytato/visualization/dot.py +++ b/pytato/visualization/dot.py @@ -184,7 +184,8 @@ class ArrayToDotNodeInfoMapper(CachedMapper[ArrayOrNames]): # Default handler, does its best to guess how to handle fields. info = self.get_common_dot_info(expr) - for field in attrs.fields(type(expr)): + # type-ignore-reason: https://github.com/python/mypy/issues/16254 + for field in attrs.fields(type(expr)): # type: ignore[misc] if field.name in info.fields: continue attr = getattr(expr, field.name) -- GitLab