title: mypy: how to best deal with random.choice
body: <p>What's the best way to handle the following mypy error - </p>
  
  <blockquote>
    <p>Incompatible types in assignment (expression has type "object", variable has type "Union[ClassOne, ClassTwo, ClassThree, ClassFour]")</p>
  </blockquote>
  
  <p>for the below loop:</p>
  
  <pre><code>def func(self) -&gt; List:
          thing = [x for x in self.Bar if x.condition]
          Foo: Union[ClassOne, ClassTwo, ClassThree, ClassFour]
          if len(thing) == 1:
              Foo = ClassOne(self.Bar)
          elif len(thing) == 2:
              Foo = random.choice([ClassTwo(self.Bar), ClassThree(self.Bar)])
          elif len(thing) == 3:
              Foo = ClassFour(self.Bar)
          result = Foo.mymethod()
  
          return result
  </code></pre>
  
  <p>As you can see I'm choosing an initialised class based on a condition and running a method on it.</p>
  
  <p>When random.choice is used though, mypy is insisting the type is object. </p>
  
  <p>Adding "object" or "Any" in the type declaration for Foo doesn't help cos then mypy complains object doesn't have the mymethod attribute. </p>