MCPcopy Create free account
hub / github.com/modelscope/modelscope / has_attr_in_class

Function has_attr_in_class

modelscope/utils/import_utils.py:526–543  ·  view source on GitHub ↗

Determine if attribute in specific class. Args: cls: target class. attribute_name: the attribute name. Returns: The attribute in the class or not.

(cls, attribute_name)

Source from the content-addressed store, hash-verified

524
525
526def has_attr_in_class(cls, attribute_name) -> bool:
527 """
528 Determine if attribute in specific class.
529
530 Args:
531 cls: target class.
532 attribute_name: the attribute name.
533
534 Returns:
535 The attribute in the class or not.
536 """
537 init_method = cls.__init__
538 signature = inspect.signature(init_method)
539
540 parameters = signature.parameters
541 param_names = list(parameters.keys())
542
543 return attribute_name in param_names

Callers 1

Calls 1

keysMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…