Esempio n. 1
0
def generate_type_new(type_obj, obj):
    if safe_isinstance(
            obj, (types.BuiltinFunctionType, class_method_descriptor_type)):
        function_info = generate_builtin_function(obj)

        new_overloads = BuiltinScraper.get_new_overloads(type_obj, obj)
        if new_overloads is not None:
            # replace overloads with better version if available
            function_info['overloads'] = new_overloads
            return 'function', function_info

    if safe_getattr(
            obj, '__doc__', ''
    ) == 'T.__new__(S, ...) -> a new object with type S, a subtype of T':
        doc_str = safe_getattr(type_obj, '__doc__', None)
        if not safe_isinstance(doc_str, str_types):
            doc_str = ''
        return ('function', {
            'doc':
            doc_str,
            'overloads': [{
                'doc': doc_str,
                'args': [{
                    'arg_format': '*',
                    'name': 'args'
                }]
            }]
        })

    return generate_member(obj)
Esempio n. 2
0
def generate_type_new(type_obj, obj):
    if safe_isinstance(obj, (types.BuiltinFunctionType, class_method_descriptor_type)):
        function_info = generate_builtin_function(obj)

        new_overloads = BuiltinScraper.get_new_overloads(type_obj, obj)
        if new_overloads is not None:
            # replace overloads with better version if available
            function_info["overloads"] = new_overloads
            return "function", function_info

    if safe_getattr(obj, "__doc__", "") == "T.__new__(S, ...) -> a new object with type S, a subtype of T":
        doc_str = safe_getattr(type_obj, "__doc__", None)
        if not safe_isinstance(doc_str, str_types):
            doc_str = ""
        return (
            "function",
            {"doc": doc_str, "overloads": [{"doc": doc_str, "args": [{"arg_format": "*", "name": "args"}]}]},
        )

    return generate_member(obj)
Esempio n. 3
0
def generate_type_new(type_obj, obj):
    if safe_isinstance(obj, (types.BuiltinFunctionType, class_method_descriptor_type)):
        function_info = generate_builtin_function(obj)

        new_overloads = BuiltinScraper.get_new_overloads(type_obj, obj)
        if new_overloads is not None:
            # replace overloads with better version if available
            function_info['overloads'] = new_overloads
            return 'function', function_info

    if safe_getattr(obj, '__doc__', '') == 'T.__new__(S, ...) -> a new object with type S, a subtype of T':
        doc_str = safe_getattr(type_obj, '__doc__', None)
        if not safe_isinstance(doc_str, str_types):
            doc_str = ''
        return (
            'function',
            {
                'doc': doc_str,
                'overloads' : [{'doc': doc_str, 'args': [{'arg_format': '*', 'name': 'args'}] }]
            }
        )

    return generate_member(obj)