title: Can mypy track string literals?
body: <p>Is there anyway to make this work</p>
  <pre><code>from typing import Literal
  def foo(bar: Literal[&quot;bar&quot;]) -&gt; Literal[&quot;foo&quot;]:
      foo = &quot;foo&quot;
      return foo
  
  
  bar = &quot;bar&quot;
  foo(bar)
  </code></pre>
  <p>Here are the errors</p>
  <pre><code>foo.py:4: error: Incompatible return value type (got &quot;str&quot;, expected &quot;Literal['foo']&quot;)
  foo.py:8: error: Argument 1 to &quot;foo&quot; has incompatible type &quot;str&quot;; expected &quot;Literal['bar']&quot;
  </code></pre>
  <p>Is pretty obvious that <code>foo</code> variable and <code>bar</code> are literals because they are assigned to literals, so this is safe, but mypy seems to not track this. Is there anything that I'm missing?</p>