title: Import a pyi (type stub file) into a normal python module
body: <p>I have a program (like a macro) that runs within a parent program and imports an API module from that program (lets call it <code>foo</code>). The problem is that that module only exists within that program, so I can't do things like run <a href="https://github.com/NiklasRosenstein/pydoc-markdown" rel="noreferrer">pydocmd</a> outside the software because the script throws a ReferenceError. To aid in my own development I have create a type stub file, <code>foo.pyi</code>, in my project directory. What I would like to do is import that type stub as a normal Python file if the import fails, to provide dummy functions and properties. Something like:</p>
  
  <pre class="lang-py prettyprint-override"><code>try:
    import foo
  except ImportError:
    from . import foo.pyi
  </code></pre>
  
  <p>This raises an error, however, as it's trying to import <code>pyi</code> from the <code>foo</code> library that does not exist in the project folder. The only other option I can think of is to have an identical copy of the .pyi file as, say "dummy_foo.py" but then I have to maintain two copies of the same file in one repo. I'd rather not do that.</p>