title: When does Python check whether a concrete subclass of an ABC implements the required methods?
body: <p>While trying to write unittests that check whether a concrete subclass of an Abstract base class really does raise a TypeError upon instantiation if one of the required methods is not implemented, I stumbled upon something which made me wonder when the check if the required methods is defined by the concrete subclass is actually performed.</p>
  
  <p>Until now I would have said: upon instantiation of the object, since this is the time when the Exception is actually raised when running the program.</p>
  
  <p>But look at this snippet:</p>
  
  <pre><code>import abc
  
  class MyABC(abc.ABC):
      @abstractmethod
      def foo(self): pass
  
  MyConcreteSubclass(MyABC):
      pass
  </code></pre>
  
  <p>As expected, trying to instantiate MyConcreteSubclass raises a TypeError:</p>
  
  <pre><code>&gt;&gt;&gt; MyConcreteSubclass()
  ---------------------------------------------------------------------------
  TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-39-fbfc0708afa6&gt; in &lt;module&gt;()
  ----&gt; 1 t = MySubclass()
  
  TypeError: Can't instantiate abstract class MySubclass with abstract methods foo
  </code></pre>
  
  <p>But what happens if I declare a valid subclass at first and then afterwards delete this method surprises me:</p>
  
  <pre><code>class MyConcreteSubclass(MyABC):
      def foo(self):
          print("bar")
  
  MyConcreteSubclass.foo
  --&gt; &lt;function __main__.MyConcreteSubclass.foo(self)&gt;
  
  
  &gt;&gt;&gt; t = MyConcreteSubclass()
  &gt;&gt;&gt; t.foo()
  bar
  
  &gt;&gt;&gt; del MyConcreteSubclass.foo
  &gt;&gt;&gt; MyConcreteSubclass.foo
  &lt;function __main__.MyABC.foo(self)&gt;
  
  &gt;&gt;&gt; t = MyConcreteSubclass()
  &gt;&gt;&gt; print(t.foo())
  None
  </code></pre>
  
  <p>This is certainly not what I expected. When inspecting MyConcreteSubclass.foo after deletion, we see that through the method Resolution order the Abstract method of the base class is retrieved, which is the same behaviour as if we haven't implemented foo in the concrete subclass in the first place.</p>
  
  <p>But after instantiation the TypeError is not raised.
  So I wonder, are the checks whether the required methods are implemented already performed when the body of the concrete subclass is evaluated by the Interpreter?
  If so, why are the TypeErrors only raised when someone tries to instantiate the subclass?</p>
  
  <p>The Tests shown above were performed using Python 3.6.5.</p>