コード例 #1
0
ファイル: soi.py プロジェクト: Marslo/VimConfig
def _parameter_objects(pyobject):
    result = []
    params = pyobject.get_param_names(special_args=False)
    hint_param = get_type_hinting_factory(pyobject.pycore.project).make_param_provider()
    for name in params:
        type_ = hint_param(pyobject, name)
        if type_ is not None:
            result.append(rope.base.pyobjects.PyObject(type_))
        else:
            result.append(rope.base.pyobjects.get_unknown())
    return result
コード例 #2
0
ファイル: soi.py プロジェクト: RationalTrip/Lab1CS
def _parameter_objects(pyobject):
    result = []
    params = pyobject.get_param_names(special_args=False)
    hint_param = get_type_hinting_factory(
        pyobject.pycore.project).make_param_provider()
    for name in params:
        type_ = hint_param(pyobject, name)
        if type_ is not None:
            result.append(rope.base.pyobjects.PyObject(type_))
        else:
            result.append(rope.base.pyobjects.get_unknown())
    return result
コード例 #3
0
ファイル: soi.py プロジェクト: Marslo/VimConfig
def infer_assigned_object(pyname):
    if not pyname.assignments:
        return
    for assignment in reversed(pyname.assignments):
        result = _infer_assignment(assignment, pyname.module)
        if isinstance(result, rope.base.builtins.BuiltinUnknown) and result.get_name() == 'NotImplementedType':
            break
        elif result == rope.base.pyobjects.get_unknown():
            break
        elif result is not None:
            return result

    hint_assignment = get_type_hinting_factory(pyname.module.pycore.project).make_assignment_provider()
    hinting_result = hint_assignment(pyname)
    if hinting_result is not None:
        return rope.base.pyobjects.PyObject(hinting_result)
    return result
コード例 #4
0
ファイル: soi.py プロジェクト: RationalTrip/Lab1CS
def infer_assigned_object(pyname):
    if not pyname.assignments:
        return
    for assignment in reversed(pyname.assignments):
        result = _infer_assignment(assignment, pyname.module)
        if isinstance(result, rope.base.builtins.BuiltinUnknown
                      ) and result.get_name() == 'NotImplementedType':
            break
        elif result == rope.base.pyobjects.get_unknown():
            break
        elif result is not None:
            return result

    hint_assignment = get_type_hinting_factory(
        pyname.module.pycore.project).make_assignment_provider()
    hinting_result = hint_assignment(pyname)
    if hinting_result is not None:
        return rope.base.pyobjects.PyObject(hinting_result)
    return result
コード例 #5
0
ファイル: soi.py プロジェクト: Marslo/VimConfig
def infer_returned_object(pyfunction, args):
    """Infer the `PyObject` this `PyFunction` returns after calling"""
    object_info = pyfunction.pycore.object_info
    result = object_info.get_exact_returned(pyfunction, args)
    if result is not None:
        return result
    result = _infer_returned(pyfunction, args)
    if result is not None:
        if args and pyfunction.get_module().get_resource() is not None:
            params = args.get_arguments(
                pyfunction.get_param_names(special_args=False))
            object_info.function_called(pyfunction, params, result)
        return result
    result = object_info.get_returned(pyfunction, args)
    if result is not None:
        return result
    hint_return = get_type_hinting_factory(pyfunction.pycore.project).make_return_provider()
    type_ = hint_return(pyfunction)
    if type_ is not None:
        return rope.base.pyobjects.PyObject(type_)
コード例 #6
0
ファイル: soi.py プロジェクト: RationalTrip/Lab1CS
def infer_returned_object(pyfunction, args):
    """Infer the `PyObject` this `PyFunction` returns after calling"""
    object_info = pyfunction.pycore.object_info
    result = object_info.get_exact_returned(pyfunction, args)
    if result is not None:
        return result
    result = _infer_returned(pyfunction, args)
    if result is not None:
        if args and pyfunction.get_module().get_resource() is not None:
            params = args.get_arguments(
                pyfunction.get_param_names(special_args=False))
            object_info.function_called(pyfunction, params, result)
        return result
    result = object_info.get_returned(pyfunction, args)
    if result is not None:
        return result
    hint_return = get_type_hinting_factory(
        pyfunction.pycore.project).make_return_provider()
    type_ = hint_return(pyfunction)
    if type_ is not None:
        return rope.base.pyobjects.PyObject(type_)