File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
python/ql/lib/semmle/python/dataflow/new/internal Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -2111,4 +2111,27 @@ module DuckTyping {
21112111 )
21122112 )
21132113 }
2114+
2115+ /**
2116+ * Gets the `__init__` function that will be invoked when `cls` is constructed,
2117+ * resolved according to the MRO.
2118+ */
2119+ Function getInit ( Class cls ) { result = invokedFunctionFromClassConstruction ( cls , "__init__" ) }
2120+
2121+ /**
2122+ * Holds if `f` overrides a method in a superclass with the same name.
2123+ */
2124+ predicate overridesMethod ( Function f ) {
2125+ exists ( Class cls | f .getScope ( ) = cls | hasMethod ( getADirectSuperclass ( cls ) , f .getName ( ) ) )
2126+ }
2127+
2128+ /**
2129+ * Holds if `f` is a property accessor (decorated with `@property`, `@name.setter`,
2130+ * or `@name.deleter`).
2131+ */
2132+ predicate isPropertyAccessor ( Function f ) {
2133+ exists ( Attribute a | a = f .getADecorator ( ) | a .getName ( ) = "setter" or a .getName ( ) = "deleter" )
2134+ or
2135+ f .getADecorator ( ) .( Name ) .getId ( ) = "property"
2136+ }
21142137}
You can’t perform that action at this time.
0 commit comments