title: python - how to specify return type hint for a method that returns a new object
body: <p>I'll first introduce my situation and then ask the question.</p>
  <p>So I already have the following code written and can not be changed:</p>
  <pre><code>class A:
      def __init__(self, number: int, letter: str):
          self.number = number
          self.letter = letter
  
      @classmethod
      def create_new(cls, number: int, letter: str):
          return cls(number, letter)
  
  </code></pre>
  <p>As you can see, the method <code>create_new</code> can create new objects from given attributes. Obviously, in real life, the class itself isn't called &quot;A&quot; and the methods are far more complicated. For the sake of the example, I distilled the staff that matters.</p>
  <p>Now, I want to add the following method to the class:</p>
  <pre><code>    def create_new_with_different_number(self, number: int):
          return self.create_new(number, self.letter)
  </code></pre>
  <p>in order to allow the user to create new, almost-identical object, with only one attribute changed (in this example - the same object only with different number).</p>
  <p>Is there a way for me to precisely indicate the return type of <code>create_new_with_different_number</code>? Something like:</p>
  <pre><code>    def create_new_with_different_number(self, number: int) -&gt; A:
          return self.create_new(number, self.letter)
  </code></pre>
  <p>won't work, since &quot;A&quot; is not defined yet when the method is being defined.</p>
  <p>P.S:
  I know the situation might sound complex and seem like a bad design, but it is what it is and I need to only add my method, not change the existing ones.</p>