Skip to content

foobar.foo

Source file: foobar/foo.py

foo module.

bar()

<div class="doc-signature highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="n">bar</span><span class="p">(</span><span class="n">data</span><span class="p">:</span> <span class="o"><</span><span class="n">span</span> <span class="n">data</span><span class="o">-</span><span class="n">autorefs</span><span class="o">-</span><span class="n">optional</span><span class="o">=</span><span class="s2">"list"</span><span class="o">></span><span class="nb">list</span><span class="o"></</span><span class="n">span</span><span class="o">></span><span class="p">[</span><span class="o"><</span><span class="n">span</span> <span class="n">data</span><span class="o">-</span><span class="n">autorefs</span><span class="o">-</span><span class="n">optional</span><span class="o">=</span><span class="s2">"int"</span><span class="o">></span><span class="nb">int</span><span class="o"></</span><span class="n">span</span><span class="o">></span><span class="p">]</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="o"><</span><span class="n">span</span> <span class="n">data</span><span class="o">-</span><span class="n">autorefs</span><span class="o">-</span><span class="n">optional</span><span class="o">=</span><span class="s2">"int"</span><span class="o">></span><span class="nb">int</span><span class="o"></</span><span class="n">span</span><span class="o">></span> <span class="o">|</span> <span class="kc">None</span><span class="p">(</span>
</span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2" href="#__codelineno-0-2"></a>    <span class="n">data</span><span class="p">:</span> <span class="n"><span data-autorefs-optional="list">list</span></span><span class="p">[</span><span class="n"><span data-autorefs-optional="int">int</span></span><span class="p">]</span> <span class="o">|</span> <span class="kc">None</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3" href="#__codelineno-0-3"></a><span class="p">)</span> <span class="o">-></span> <span class="n"><span data-autorefs-optional="int">int</span></span> <span class="o">|</span> <span class="kc">None</span>
</span></code></pre></div>

Sum list of integers.

Parameters:

  • data ((list[int], None), default: None ) –

    optional list of integers (default: None).

Returns:

  • int | None

    None if data=None else the integer sum of data.

Source code in foobar/foo.py
def bar(data: list[int] | None = None) -> int | None:
    """Sum list of integers.

    Args:
        data (list[int], None): optional list of integers (default: None).

    Returns:
        `None` if `data=None` else the integer sum of `data`.
    """
    if data is not None:
        return sum(data)
    return None