Class ClassObject::ClassObject

A class whose instances represents Python classes. Instances of this class represent either builtin classes such as list or str, or program-defined Python classes present in the source code.

Generally there is a one-to-one mapping between classes in the Python program and instances of this class in the database. However, that is not always the case. For example, dynamically generated classes may share a single QL class instance. Also the existence of a class definition in the source code does not guarantee that such a class will ever exist in the running program.

Direct supertypes

Indirect supertypes

Known direct subtypes

Predicates

assignedInInit
attributeRefersTo

Whether the named attribute refers to the object and origin

attributeRefersTo

Whether the named attribute refers to the object, class and origin

booleanValue

The Boolean value of this object if it always evaluates to true or false. For example: false for None, true for 7 and no result for int(x)

declaredAttribute

Returns an attribute declared on this class (not on a super-class)

declaredMetaClass
declaresAttribute

Returns an attribute declared on this class (not on a super-class)

failedInference

Has type inference failed to compute the full class hierarchy for this class for the reason given.

failedInference

Has type inference failed to compute the full class hierarchy for this class

getABaseType

Gets a base class of this class

getACall

Gets a call to this class. Note that the call may not create a new instance of this class, as that depends on the __new__ method of this class.

getAMethodCalledFromInit
getASuperType

Gets a super class of this class (includes transitive super classes)

getAnImproperSuperType

Gets a super class of this class (includes transitive super classes) or this class

getBaseType

Gets the nth base class of this class

getImportTimeScope
getMetaClass

Gets the metaclass for this class

getMro
getMroItem

Gets the MRO for this class. ClassObject sup occurs at index in the list of classes. this has an index of 1, the next class in the MRO has an index of 2, and so on.

getName

Gets the short (unqualified) name of this class

getProbableSingletonInstance

Gets an object which is the sole instance of this class, if this class is probably a singleton. Note the ‘probable’ in the name; there is no guarantee that this class is in fact a singleton. It is guaranteed that getProbableSingletonInstance() returns at most one Object for each ClassObject.

getPyClass

Gets the scope associated with this class, if it is not a builtin class

getQualifiedName

Gets the qualified name for this class. Should return the same name as the __qualname__ attribute on classes in Python 3.

hasABase

Whether this class has a base class

hasAttribute

Whether this class has a attribute named name, either declared or inherited.

hasDuplicateBases

Holds if this class has duplicate base classes

isAbstract
isCallable
isCollection

Synonymous with isContainer(), retained for backwards compatibility.

isContainer

Holds if this class is a container(). That is, does it have a getitem method.

isContextManager
isDescriptorType

Holds if this class is a descriptor

isIterable

Holds if this class is an iterable.

isIterator

Holds if this class is an iterator.

isLegalExceptionType

Whether this class is a legal exception class. What constitutes a legal exception class differs between major versions

isMapping

Holds if this class is a mapping.

isNewStyle

Whether this class is a new style class. A new style class is one that implicitly or explicitly inherits from object.

isOverridingDescriptorType

Holds if this class is an overriding descriptor

isSequence

Holds if this class is probably a sequence.

isSubclassOf

Holds if this class is an improper subclass of the other class. True if this is a sub-class of other or this is the same class as other.

lookupAttribute

Returns an attribute as it would be when looked up at runtime on this class. Will include attributes of super-classes

lookupMro

Looks up an attribute by searching this class’ MRO starting at start

nextInMro

Returns the next class in the MRO of ‘this’ after ‘sup’

toString
unhashable

Holds if this class is unhashable

unknowableAttributes

Whether it is impossible to know all the attributes of this class. Usually because it is impossible to calculate the full class hierarchy or because some attribute is too dynamic.

Inherited predicates

getAnInferredType

Gets an inferred type for this object, without using inter-procedural analysis. WARNING: The lack of context makes this less accurate than f.refersTo(this, result, _) for a control flow node ‘f’

from Object
getOrigin

Gets the point in the source code from which this object “originates”.

from Object
hasLocationInfofrom Object
hasLongName

Holds if this object can be referred to by longName For example, the modules dict in the sys module has the long name sys.modules and the name os.path.join will refer to the path joining function even though it might be declared in the posix or nt modules. Long names can have no more than three dots after the module name.

from Object
isBuiltin

Whether this a builtin object. A builtin object is one defined by the implementation, such as the integer 4 or by a native extension, such as a NumPy array class.

from Object
isC

Retained for backwards compatibility. See Object.isBuiltin()

from Object
overrides

Whether this overrides o. In this context, “overrides” means that this object is a named attribute of a some class C and o is a named attribute of another class S, both attributes having the same name, and S is a super class of C.

from Object
simpleClass

Gets the class of this object for simple cases, namely constants, functions, comprehensions and built-in objects.

from Object

Charpred