title: How to use literal value as generic parameter in Python?
body: <p>I'm trying to hint a <code>bytes</code> object with fixed length:</p>
  <pre class="lang-py prettyprint-override"><code>data: FixedLengthBytes[100]
  </code></pre>
  <p>But mypy complains: <code>Invalid type: try using Literal[100] instead?</code>. Because it requires the value between brackets to be a type, not int literal.</p>
  <p>It might be relevant to <code>typing.Annotated</code> or <code>types.GenericAlias</code>. Following code works perfect at run-time, but cannot pass type check:</p>
  <pre class="lang-py prettyprint-override"><code>class FixedLengthBytes:
      def __class_getitem__(cls, length: int) -&gt; Type[bytes]:
          return Annotated[bytes, FixedLength(length)]
  </code></pre>
  <hr />
  <p>This specific demand can be workarounded by directly using <code>Annotated</code>, but it's verbose and less encapsulated.</p>
  <pre class="lang-py prettyprint-override"><code>data: Annotated[bytes, FixedLength(100)]
  </code></pre>