title: Python private inheritance? How to trick isinstance()?
body: <p>Snippet of django core code:</p>
  
  <pre><code>class ForeignKey(RelatedField, Field):
  
      ...
  
      def db_type(self, connection):
          rel_field = self.rel.get_related_field()
          if (isinstance(rel_field, AutoField) or
                  (not connection.features.related_fields_match_type and
                  isinstance(rel_field, (PositiveIntegerField,
                                         PositiveSmallIntegerField)))):
              return IntegerField().db_type(connection=connection)
          return rel_field.db_type(connection=connection)
  </code></pre>
  
  <p>This code is very bad, because if I define a custom field which inherits from <code>AutoField</code>, then my db_type method will be ignored. </p>
  
  <p>What I would like to do is to hide the fact that my class is an instance of <code>AutoField</code>. In C++, I would do that by private inheritance. </p>
  
  <p>Is there any way to trick <code>isinstance</code> to return <code>False</code> or to hide inheritance?</p>
  
  <p>Code of my cutom field:</p>
  
  <pre><code>class MyAutoField(models.AutoField):
  
      def __init__(self, length, *args, **kwargs):
          self.length = length
          super(MyAutoField, self).__init__(*args, **kwargs)
  
      def db_type(self, connection):
          if connection.vendor == 'oracle':
              return 'NUMBER(%s,0)' % (self.length)
          if connection.vendor == 'postgresql':
              if self.length &lt;= 4:
                  return 'smallint'
              if self.length &lt;= 9:
                  return 'integer'
              return 'bigint'
          return super(MyAutoField, self).db_type(connection)
  </code></pre>