from typing import Union
from pyfields import has_fields
has_fields(Union[int, float])
Leads to a non-user-friendly error message:
Traceback (most recent call last):
...
File "<ipython-input-4-0e8bf0e2111b>", line 1, in <module>
has_fields(Union[int, float])
File "\site-packages\pyfields\helpers.py", line 146, in has_fields
return any(yield_fields(cls, include_inherited=include_inherited))
File "\site-packages\pyfields\helpers.py", line 71, in yield_fields
where_cls = reversed(getmro(cls)) if ancestors_first else getmro(cls)
File "C:\Python38\lib\inspect.py", line 489, in getmro
return cls.__mro__
File "C:\Python38\lib\typing.py", line 760, in __getattr__
raise AttributeError(attr)
AttributeError: __mro__
We should rather return None or raise a proper ValueError indicating that cls is not an actual class.