Skip to content

[mypy] Fix Item "function" of "Union[Any, Callable[..., Any]]" has no attribute "__iter__"

Nsukami Patrick requested to merge topic/default/fix-not-iterable into branch/default

Error: yams/schema2dot.py:52: error: Item "function" of "Union[Any, Callable[..., Any]]" has no attribute "iter" (not iterable) for rel in eschema.ordered_relations()

Context: Revealed type for eschema.ordered_relations() is "Union[Any, def (*Any, **Any) -> Any]", not List["RelationSchema] That is because, ordered_relations is decorated with @cache

Solutions:

  • either, remove the @cache decorator before the ordered_relations method
  • either, cast again to List (picked solution)

Merge request reports

Loading