Type hint for a function that returns only a specific set of values
<p>I have a function that can only return <code>a</code>, <code>b</code> or <code>c</code>, all of them are of type <code>T</code>. I want to include this fact in the signature because of the special meaning they carry in the context of the function. How do I do that?</p>
<p>Currently, I use this</p>
<pre><code>def fun(...) -&gt; &quot;a or b or c&quot;:
    #briefly explain the meaning of a, b and c in its docstring
</code></pre>
<p>Is that the correct one?</p>
<p>I know that I can do this</p>
<pre><code>def fun(...) -&gt; T:
    # briefly explain the meaning of a, b and c in its docstring
</code></pre>
<p>but as I said, I want to express in the signature that the function only returns those specific values.</p>