title: Dependency Inversion in Python
body: <p>I've started to apply <a href="https://en.wikipedia.org/wiki/SOLID" rel="noreferrer">SOLID principles</a> to my projects. All of them are clear for me, except dependency inversion, because in Python we have no change to define variable in type of some class inside another class (or maybe just I don't know). So I've realized Dependency Inversion principle in two forms, and want to know which of them is true, how can I correct them. Here are my codes:</p>
  <p><code>d1.py</code>:</p>
  <pre><code>class IFood:
      def bake(self, isTendir: bool): pass
      
  class Production:
      def __init__(self):
          self.food = IFood()
      
      def produce(self):
          self.food.bake(True)
          
  class Bread(IFood):
      def bake(self, isTendir:bool):
          print(&quot;Bread was baked&quot;)
  </code></pre>
  <p><code>d2.py</code>:</p>
  <pre><code>from abc import ABC, abstractmethod
  class Food(ABC):
      @abstractmethod
      def bake(self, isTendir): pass
      
  class Production():
      def __init__(self):
          self.bread = Bread()
      
      def produce(self):
          self.bread.bake(True)
          
  class Bread(Food):
      def bake(self, isTendir:bool):
          print(&quot;Bread was baked&quot;)
  </code></pre>