<p dir="auto">Now that flask 2.0.0 has a <code class="notranslate">py.typed</code> file, the flask types are preferred over the typeshed hints. When running mypy on my code, I now see errors like the following:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" app.py:6: error: Module 'flask' does not explicitly export attribute 'Flask'; implicit reexport disabled
 app.py:6: error: Module 'flask' does not explicitly export attribute 'render_template'; implicit reexport disabled
 app.py:6: error: Module 'flask' does not explicitly export attribute 'request'; implicit reexport disabled
 app.py:6: error: Module 'flask' does not explicitly export attribute 'flash'; implicit reexport disabled
 app.py:6: error: Module 'flask' does not explicitly export attribute 'send_file'; implicit reexport disabled"><pre class="notranslate"><code class="notranslate"> app.py:6: error: Module 'flask' does not explicitly export attribute 'Flask'; implicit reexport disabled
 app.py:6: error: Module 'flask' does not explicitly export attribute 'render_template'; implicit reexport disabled
 app.py:6: error: Module 'flask' does not explicitly export attribute 'request'; implicit reexport disabled
 app.py:6: error: Module 'flask' does not explicitly export attribute 'flash'; implicit reexport disabled
 app.py:6: error: Module 'flask' does not explicitly export attribute 'send_file'; implicit reexport disabled
</code></pre></div>
<p dir="auto">In <code class="notranslate">flask/__init__.py</code> there are lines like this:</p>
<p dir="auto"></p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/pallets/flask/blob/d575de5159a6e40944275763c9ada2801214058b/src/flask/__init__.py#L7">flask/src/flask/__init__.py</a>
    </p>
    <p class="mb-0 color-fg-muted">
         Line 7
      in
      <a data-pjax="true" class="commit-tease-sha" href="/pallets/flask/commit/d575de5159a6e40944275763c9ada2801214058b">d575de5</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L7" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="7"></td>
          <td id="LC7" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-k">from</span> .<span class="pl-s1">app</span> <span class="pl-k">import</span> <span class="pl-v">Flask</span> </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></p>
<p dir="auto">However, mypy expects that these reexports should either have an <code class="notranslate">__all__</code> to explicitly say which variables are being reexported, or to change the import to <code class="notranslate">from .app import Flask as Flask</code></p>
<p dir="auto">In typeshed there is an example of how this was done before flask including typing: <a href="https://github.com/python/typeshed/blob/6bb1d885c696914e5900329c3d0b6bf2bfefee81/stubs/Flask/flask/__init__.pyi">https://github.com/python/typeshed/blob/6bb1d885c696914e5900329c3d0b6bf2bfefee81/stubs/Flask/flask/__init__.pyi</a></p>
<p dir="auto">Environment:</p>
<ul dir="auto">
<li>Python version: 3.9</li>
<li>Flask version: 2.0.0</li>
</ul>
<p dir="auto">Python 3.9.5 + mypy 0.812</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# magic.py
from jinja2 import Environment"><pre class="notranslate"><span class="pl-c"># magic.py</span>
<span class="pl-k">from</span> <span class="pl-s1">jinja2</span> <span class="pl-k">import</span> <span class="pl-v">Environment</span></pre></div>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="mypy ./magic.py
Success: no issues found in 1 source file"><pre class="notranslate">mypy ./magic.py
Success: no issues found <span class="pl-k">in</span> 1 <span class="pl-c1">source</span> file</pre></div>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="mypy ./magic.py --strict
magic.py:1: error: Module 'jinja2' does not explicitly export attribute 'Environment'; implicit reexport disabled
Found 1 error in 1 file (checked 1 source file)"><pre class="notranslate">mypy ./magic.py --strict
magic.py:1: error: Module <span class="pl-s"><span class="pl-pds">'</span>jinja2<span class="pl-pds">'</span></span> does not explicitly <span class="pl-k">export</span> attribute <span class="pl-s"><span class="pl-pds">'</span>Environment<span class="pl-pds">'</span></span><span class="pl-k">;</span> implicit reexport disabled
Found 1 error <span class="pl-k">in</span> 1 file (checked 1 <span class="pl-c1">source</span> file)</pre></div>
<p dir="auto">Thanks <g-emoji class="g-emoji" alias="+1" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f44d.png">👍</g-emoji></p>