Check whether *cls* is a class with *attrs* attributes. Args: cls (type): Class to introspect. Raises: TypeError: If *cls* is not a class. Returns: bool:
(cls)
| 352 | |
| 353 | |
| 354 | def has(cls): |
| 355 | class="st">""" |
| 356 | Check whether *cls* is a class with *attrs* attributes. |
| 357 | |
| 358 | Args: |
| 359 | cls (type): Class to introspect. |
| 360 | |
| 361 | Raises: |
| 362 | TypeError: If *cls* is not a class. |
| 363 | |
| 364 | Returns: |
| 365 | bool: |
| 366 | class="st">""" |
| 367 | attrs = getattr(cls, class="st">"__attrs_attrs__", None) |
| 368 | if attrs is not None: |
| 369 | return True |
| 370 | |
| 371 | class="cm"># No attrs, maybe it's a specialized generic (A[str])? |
| 372 | generic_base = get_generic_base(cls) |
| 373 | if generic_base is not None: |
| 374 | generic_attrs = getattr(generic_base, class="st">"__attrs_attrs__", None) |
| 375 | if generic_attrs is not None: |
| 376 | class="cm"># Stick it on here for speed next time. |
| 377 | cls.__attrs_attrs__ = generic_attrs |
| 378 | return generic_attrs is not None |
| 379 | return False |
| 380 | |
| 381 | |
| 382 | def assoc(inst, **changes): |