CodeQL library for Python
codeql/python-all 0.7.1 (changelog, source)
Search

Class PythonClassObjectInternal

A class that is defined in Python source.

Import path

import semmle.python.objects.Classes

Direct supertypes

Indirect supertypes

Predicates

attributesUnknown

Holds if the attributes of this object are wholly or partly unknowable

callResult

Holds if obj is the result of calling this and origin is the origin of obj with callee context callee.

callResult

Holds if obj is the result of calling this and origin is the origin of obj.

calleeAndOffset

Holds if the function scope is called when this object is called and paramOffset is the difference from the parameter position and the argument position. For a normal function paramOffset is 0. For classes and bound-methods it is 1. Used by points-to to help determine flow from arguments to parameters.

functionAndOffset

Holds if the object function is called when this object is called and paramOffset is the difference from the parameter position and the argument position. For a normal function paramOffset is 0. For classes and bound-methods it is 1. This is used to implement the CallableValue public API.

getBuiltin

Gets the Builtin for this object, if any. Objects (except unknown and undefined values) should attempt to return exactly one result for either this method or getOrigin().

getClass

Gets the class of this object.

getClassDeclaration

Gets the class declaration for this object, if it is a class with a declaration.

getOrigin

Gets a control flow node that represents the source origin of this object, if it has a meaningful location in the source code. This method exists primarily for providing backwards compatibility and locations for source objects. Source code objects should attempt to return exactly one result for this method.

getScope

Gets the scope for this Python class

introducedAt

Holds if this object is introduced into the code base at node given the context This means that node, in context, points-to this object, but the object has not flowed there from anywhere else. Examples: * The object None is “introduced” by the keyword “None”. * A bound method would be “introduced” when relevant attribute on an instance is accessed. In x = X(); x.m x.m introduces the bound method.

lookup

Looks up the attribute name on this class. Note that this may be different from this.attr(name). For example given the class: class C: @classmethod def f(cls): pass this.lookup("f") is equivalent to C.__dict__['f'], which is the class-method whereas this.attr("f") is equivalent toC.f`, which is a bound-method.

notTestableForEquality

True if this “object” can be meaningfully analyzed to determine the boolean value of equality tests on it. For example, None or int can be, but int() or an unknown string cannot.

toString

Gets a textual representation of this element.

Inherited predicates

attribute

Approximation to descriptor protocol, skipping meta-descriptor protocol

from ClassObjectInternal
binds

Holds if attribute lookup on this object may “bind” instance to descriptor. Here “bind” means that instance is passed to the descriptor.__get__() method at runtime. The term “bind” is used as this most likely results in a bound-method.

from ClassObjectInternal
booleanValue

Gets the boolean value of this object. This may be both true and false if the “object” represents a set of possible objects.

from ClassObjectInternal
contextSensitiveCalleefrom ClassObjectInternal
descriptorGetClass

Holds if the result of attribute access on the class holding this descriptor is value, originating at origin For example, although T.__dict__['name'] = classmethod(f), T.name is a bound-method, binding f and T

from ClassObjectInternal
descriptorGetInstance

Holds if the result of attribute access on an instance of a class holding this descriptor is value, originating at origin For example, with T.__dict__['name'] = classmethod(f), T().name is a bound-method, binding f and T

from ClassObjectInternal
getIterNext

Gets the ‘object’ resulting from iterating over this object. Used in the context for i in this:. The result is the ‘object’ assigned to i.

from ClassObjectInternal
getName

Gets the name of this of this object if it has a meaningful name. Note that the name of an object is not necessarily the name by which it is called For example the function named posixpath.join will be called os.path.join.

from ClassObjectInternal
getSource

For backwards compatibility shim – Not all objects have a “source”. Objects (except unknown and undefined values) should attempt to return exactly one result for this method.

from ObjectInternal
hasAttribute

Holds if this value has the attribute name

from ClassObjectInternal
intValue

Gets the integer value of things that have integer values and whose integer value is tracked. That is, some ints, mainly small numbers, and bools.

from ClassObjectInternal
isBuiltinfrom ObjectInternal
isClass

True if this “object” is a class. That is, its class inherits from type

from ClassObjectInternal
isDescriptor

Holds if this object is a descriptor. Holds, for example, for functions and properties and not for integers.

from ClassObjectInternal
isIterableSubclass

Holds if this is a subclass of the Iterable abstract base class.

from ClassObjectInternal
isNotSubscriptedTypefrom ClassObjectInternal
isSpecial

Holds if this is a class whose instances we treat specially, rather than as a generic instance. For example, type or int.

from ClassObjectInternal
length

Gets the length of the sequence that this “object” represents. Always returns a value for a sequence, will be -1 if the object has no fixed length.

from ClassObjectInternal
strValue

Gets the string value of things that have string values. That is, strings.

from ClassObjectInternal
subscriptUnknown

Holds if the result of subscripting this object are wholly or partly unknowable

from ClassObjectInternal
useOriginAsLegacyObject

Holds if this ‘object’ represents an entity that should be exposed to the legacy points_to API This should hold for almost all objects that do not have an underlying DB object representing their source, for example super objects and bound-method. This should not hold for objects that are inferred to exists by an import statements or the like, but which aren’t in the database.

from ClassObjectInternal