How can mypy ignore a single line in a source file? : <p>I'm using <a href="http://mypy-lang.org/" rel="noreferrer">mypy</a> in my python project for type checking. I'm also using PyYAML for reading and writing the project configuration files. Unfortunately, when using the <a href="http://pyyaml.org/wiki/PyYAMLDocumentation" rel="noreferrer">recommended import mechanism from the PyYAML documentation</a> this generates a spurious error in a try/except clause that attempts to import native libraries:</p>

<pre><code>from yaml import load, dump
try:
    from yaml import CLoader as Loader, CDumper as Dumper
except ImportError:
    from yaml import Loader, Dumper
</code></pre>

<p>On my system <code>CLoader</code> and <code>CDumper</code> aren't present, which results in the errors <code>error: Module 'yaml' has no attribute 'CLoader'</code> and <code>error: Module 'yaml' has no attribute 'CDumper'</code>.</p>

<p>Is there a way to have mypy ignore errors on this line? I was hoping that I could do something like this to have mypy skip that line:</p>

<pre><code>from yaml import load, dump
try:
    from yaml import CLoader as Loader, CDumper as Dumper  # nomypy
except ImportError:
    from yaml import Loader, Dumper
</code></pre>
