Will torch script support typing.Union?

username: songzw
cooked: <aside class="onebox githubissue" data-onebox-src="https://github.com/pytorch/pytorch/issues/23420">
  <header class="source">

      <a href="https://github.com/pytorch/pytorch/issues/23420" target="_blank" rel="noopener nofollow ugc">github.com/pytorch/pytorch</a>
  </header>

  <article class="onebox-body">
    <div class="github-row">
  <div class="github-icon-container" title="Issue">
	  <svg width="60" height="60" class="github-icon" viewBox="0 0 14 16" aria-hidden="true"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg>
  </div>

  <div class="github-info-container">
    <h4>
      <a href="https://github.com/pytorch/pytorch/issues/23420" target="_blank" rel="noopener nofollow ugc">Will the Jit support typehint OPTIONAL or UNION?</a>
    </h4>

    <div class="github-info">
      <div class="date">
        opened <span class="discourse-local-date" data-format="ll" data-date="2019-07-26" data-time="06:59:13" data-timezone="UTC">06:59AM - 26 Jul 19 UTC</span>
      </div>

        <div class="date">
          closed <span class="discourse-local-date" data-format="ll" data-date="2019-07-26" data-time="11:40:37" data-timezone="UTC">11:40AM - 26 Jul 19 UTC</span>
        </div>

      <div class="user">
        <a href="https://github.com/NeilWangziyu" target="_blank" rel="noopener nofollow ugc">
          <img alt="NeilWangziyu" src="https://avatars.githubusercontent.com/u/16078718?v=4" class="onebox-avatar-inline" width="20" height="20">
          NeilWangziyu
        </a>
      </div>
    </div>

    <div class="labels">
        <span style="display:inline-block;margin-top:2px;background-color: #B8B8B8;padding: 2px;border-radius: 4px;color: #fff;margin-left: 3px;">
          oncall: jit
        </span>
    </div>
  </div>
</div>

  <div class="github-row">
    <p class="github-body-container">## ❓ Questions and Help

Will the Jit support typehint OPTIONAL or UNION?

A<span class="show-more-container"><a href="" rel="noopener" class="show-more">…</a></span><span class="excerpt hidden">s the title indicates, will jit support we use UNION and Optional to indicate the type of input/output.</span></p>
  </div>

  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>
<aside class="quote" data-post="7" data-topic="60845">
  <div class="title">
    <div class="quote-controls"></div>
    <img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/zetyquickly/48/22489_2.png" class="avatar">
    <a href="https://discuss.pytorch.org/t/jit-mobile-is-isinstance-supposed-to-work-with-torchscript/60845/7">[JIT] [Mobile] Is isinstance() supposed to work with TorchScript</a> <a class="badge-category__wrapper " href="/c/jit/13"><span data-category-id="13" data-drop-close="true" class="badge-category " title="A category for TorchScript and the PyTorch JIT compiler"><span class="badge-category__name">jit</span></span></a>
  </div>
  <blockquote>
    This returns None but anyway I haven’t looked for that functionality <img width="20" height="20" src="https://discuss.pytorch.org/images/emoji/apple/stuck_out_tongue.png?v=12" title="stuck_out_tongue" alt="stuck_out_tongue" class="emoji">
  </blockquote>
</aside>
<p>
any workaround?</p>

username: richard
cooked: <p>I think torchscript supports Optional: <a href="https://pytorch.org/docs/master/jit.html#optional-type-refinement">https://pytorch.org/docs/master/jit.html#optional-type-refinement</a>.</p>
<p>TorchScript doesn’t support Union. If you have a use case, opening a feature request on the repository (instead of a question) might be the way to go.</p>