typing module - String Literal Type
<p>I'm using the new Python 3.5 module <a href="https://docs.python.org/3/library/typing.html#module-typing" rel="noreferrer">typing</a> and it has been joyous.</p>

<p>I was wondering how one might specify a type based on an exact string literal. For example, a function is guaranteed to return one of the four strings - "North", "West", "East", "South - how can we express that as a specific type variable, instead of just <code>str</code>.</p>

<p>I looked through the documentation, finding the <code>Union</code> type and the <code>TypeVar</code> function, but was unable to find an answer.</p>

<p>An example function expressing this problem:</p>

<pre><code>def compute_quadrant(x: int, y: int) -&gt; str:
    if x &gt; 0 and y &gt; 0:
        return 'I'
    elif x &lt; 0 and y &gt; 0:
        return 'II'
    elif x &lt; 0 and y &lt; 0:
        return 'III'
    elif x &gt; 0 and y &lt; 0:
        return 'IV'
</code></pre>

<p>Instead of just returning <code>str</code>, I'd like to to return a more specific type that is one of four values - <code>"I"</code>, <code>"II"</code>, <code>"III"</code>, or <code>"IV"</code>.</p>

<p>In Typescript, one can do: <code>type Quadrant = "I" | "II" | "III" | "IV"</code> - is there any nice Python sugar for this use case with the <code>typing</code> module?</p>