-
-
Notifications
You must be signed in to change notification settings - Fork 401
Closed
Description
Say I have
import attr
@attr.s(kw_only=True, frozen=True)
class A:
a: int = attr.ib()
obj = A(a=1)
Then how do I do something like isinstance(obj, attrs)
to check if this class is attrs decorated?
it seems by playing with it we have
>> dir(obj)
['__annotations__',
'__attrs_attrs__',
'__class__',
'__delattr__',
'__dict__',
'__dir__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__gt__',
'__hash__',
'__init__',
'__init_subclass__',
'__le__',
'__lt__',
'__module__',
'__ne__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__setattr__',
'__sizeof__',
'__str__',
'__subclasshook__',
'__weakref__',
'a']
is it always correct to use '__attrs_attrs__' in dir(obj)
to check whether obj belongs to a attrs decorated class?
Metadata
Metadata
Assignees
Labels
No labels