File: animals.py

package info (click to toggle)
sunpy-sphinx-theme 2.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 852 kB
  • sloc: python: 663; javascript: 457; makefile: 6
file content (174 lines) | stat: -rw-r--r-- 3,717 bytes parent folder | download
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
"""
This module provides a collection of functions.
"""

from sunpy.util.decorators import deprecated

__all__ = [
    "Animal",
    "a_really_long_function_name_just_to_see_what_happens",
    "function",
]


@deprecated("1.0", alternative="sunpy.net.Fido")
class Animal:
    """
    A deprecated class used to represent an Animal.

    .. note::

        * This is a note.

    .. warning::

        * This is a warning.

    Attributes
    ----------
    name : `str`
        The name of the animal.
    sound : `str`
        The sound that the animal makes.
    num_legs : int
        The number of legs the animal has (default 4).

    Examples
    --------
    >>> import datetime
    >>> datetime.datetime(2019, 8, 16, 22, 46, 37, 856437)
    datetime.datetime(2019, 8, 16, 22, 46, 37, 856437)

    References
    ----------
    * https://realpython.com/documenting-python-code/
    """

    says_str = "A {name} says {sound}"

    def __init__(self, name, sound, num_legs=5) -> None:
        """
        Parameters
        ----------
        name : `str`
            The name of the animal.
        sound : `str`
            The sound the animal makes.
        num_legs : int, optional
            The number of legs the animal (default is 5).
        """
        self.name = name
        self.sound = sound
        self.num_legs = num_legs

    def says(self, sound=None) -> None:
        """
        Prints what the animals name is and what sound it makes.

        If the argument `sound` isn't passed in, the default animal
        sound is used.

        Parameters
        ----------
        sound : `str`, optional
            The sound the animal makes (default is `None`),

        Raises
        ------
        `NotImplementedError`
            If no sound is set for the animal or passed in as a
            parameter.

        References
        ----------
        * `A URL. <www.sunpy.org>`__
        """
        if self.sound is None and sound is None:
            msg = "Silent Animals are not supported!"
            raise NotImplementedError(msg)


def function() -> None:
    """
    Prints what the animals name is and what sound it makes.

    If the argument `sound` isn't passed in, the default animal
    sound is used.

    .. note::

        * This is a note.

    .. warning::

        * This is a warning.

    Parameters
    ----------
    sound : `str`, optional
        The sound the animal makes (default is `None`).

    Returns
    -------
    `list`
        A list.

    Raises
    ------
    `NotImplementedError`
        If no sound is set for the animal or passed in as a
        parameter.

    Examples
    --------
    >>> import datetime
    >>> datetime.datetime(2019, 8, 16, 22, 46, 37, 856437)
    datetime.datetime(2019, 8, 16, 22, 46, 37, 856437)

    References
    ----------
    * `A URL. <www.sunpy.org>`__
    """


def a_really_long_function_name_just_to_see_what_happens() -> None:
    """
    Prints what the animals name is and what sound it makes.

    If the argument `sound` isn't passed in, the default animal
    sound is used.

    .. note::

        * This is a note.

    .. warning::

        * This is a warning.

    Parameters
    ----------
    sound : `str`, optional
        The sound the animal makes (default is `None`).

    Returns
    -------
    `list`
        A list.

    Raises
    ------
    `NotImplementedError`
        If no sound is set for the animal or passed in as a
        parameter.

    Examples
    --------
    >>> import datetime
    >>> datetime.datetime(2019, 8, 16, 22, 46, 37, 856437)
    datetime.datetime(2019, 8, 16, 22, 46, 37, 856437)

    References
    ----------
    * `A URL. <www.sunpy.org>`__
    """