MCPcopy Create free account
hub / github.com/apache/madlib / make_python_instance

Method make_python_instance

src/madpack/yaml/constructor.py:534–549  ·  view source on GitHub ↗
(self, suffix, node,
            args=None, kwds=None, newobj=False)

Source from the content-addressed store, hash-verified

532 class classobj: pass
533
534 def make_python_instance(self, suffix, node,
535 args=None, kwds=None, newobj=False):
536 if not args:
537 args = []
538 if not kwds:
539 kwds = {}
540 cls = self.find_python_name(suffix, node.start_mark)
541 if newobj and isinstance(cls, type(self.classobj)) \
542 and not args and not kwds:
543 instance = self.classobj()
544 instance.__class__ = cls
545 return instance
546 elif newobj and isinstance(cls, type):
547 return cls.__new__(cls, *args, **kwds)
548 else:
549 return cls(*args, **kwds)
550
551 def set_python_instance_state(self, instance, state):
552 if hasattr(instance, '__setstate__'):

Callers 2

Calls 1

find_python_nameMethod · 0.95

Tested by

no test coverage detected