title: warning: 'X' in try block with 'except ImportError' should also be defined in except block
body: <p>I am trying to write a wrapper around two similar libraries which would give me a common API to both of them. Example:</p>
  
  <pre><code># file XY.version.py
  try:
      import X  # primary library
      __version__ = X.__version__
  except ImportError:
      import Y  # fallback library
      __version__ = Y.__y_version__
  </code></pre>
  
  <p>PyCharm shows warning <code>"'X' in try block with 'except ImportError' should also be defined in except block"</code>. Is there any simple way to restructure code to get rid of the message? Of course I could do <code>X = None</code> at the very beginning or in the <code>except</code> block but this feels artificial since I only need to import <code>X</code> in order to get the version. Ideally I do not want to keep traces of the import in the namespace. Of course I could theoretically do <code>del X</code> at the end of the <code>try</code> block but this is something I have not seen anywhere so I assume people do not use it and btw. it does not remove the warning message in PyCharm.</p>
  
  <p>Note: I know this is similar to <a href="https://stackoverflow.com/questions/35901210/checking-module-name-inside-except-importerror">Checking module name inside &#39;except ImportError&#39;</a> but I believe this is not the same.</p>