summaryrefslogtreecommitdiff
path: root/tests/functional/ext/docparams/return/missing_return_doc_required_Numpy.py
blob: 8cc59f0ac11c86fada2a25553b45b79bf9fb182c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
"""Tests for missing-return-doc and missing-return-type-doc for Numpy style docstrings
with accept-no-returns-doc = no"""
# pylint: disable=function-redefined, invalid-name, undefined-variable, missing-function-docstring
# pylint: disable=unused-argument, too-few-public-methods


def my_func(self, doc_type):  # [missing-return-doc]
    """warn_partial_numpy_returns_type

    Arguments
    ---------
    doc_type : str
        Numpy

    Returns
    -------
    bool
    """
    return False


def my_func(self, doc_type):  # [missing-return-doc, missing-return-type-doc]
    """warn_missing_numpy_returns

    Arguments
    ---------
    doc_type : str
        Numpy
    """
    return False


def my_func(self):  # [missing-return-doc]
    """warns_numpy_return_list_of_custom_class_without_description

    Returns
    -------
        list(:class:`mymodule.Class`)
    """
    return [mymodule.Class()]


class Foo:
    """test_finds_missing_property_return_type_numpy
    Example of a property having return documentation in
    a numpy style docstring
    """

    @property
    def foo_prop(self):  # [missing-return-type-doc]
        """docstring ...

        Raises
        ------
        RuntimeError
            Always
        """
        raise RuntimeError()
        return 10  # [unreachable]


class Foo:
    """test_ignores_non_property_return_type_numpy
    Example of a class function trying to use `type` as return
    documentation in a numpy style docstring
    """

    def foo_method(self):  # [missing-return-doc, missing-return-type-doc]
        """int: docstring ...

        Raises
        ------
        RuntimeError
            Always
        """
        print(self)
        raise RuntimeError()
        return 10  # [unreachable]


class Foo:
    """test_non_property_annotation_return_type_numpy
    Example of a class function trying to use `type` as return
    documentation in a numpy style docstring
    """

    def foo_method(self) -> int:  # [missing-return-doc]
        """int: docstring ...

        Raises
        ------
        RuntimeError
            Always
        """
        print(self)
        raise RuntimeError()
        return 10  # [unreachable]