Utility functions used in this specification.
Returns True if class_ has a field with the given name.
True
class_
name
def has_field(class_: Any, name: str) -> bool:
"""
Returns `True` if `class_` has a field with the given `name`.
try:
all_fields = fields(class_)
except TypeError:
return False
return any(x.name == name for x in all_fields)