File tree Expand file tree Collapse file tree 5 files changed +14
-13
lines changed
Expand file tree Collapse file tree 5 files changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -84,11 +84,7 @@ predicate in_notebook(Expr e) {
8484}
8585
8686FunctionObject assertRaises ( ) {
87- exists ( ModuleObject unittest , ClassObject testcase |
88- unittest .getName ( ) = "unittest" and
89- testcase = unittest .getAttribute ( "TestCase" ) and
90- result = testcase .lookupAttribute ( "assertRaises" )
91- )
87+ result = ModuleObject:: named ( "unittest" ) .getAttribute ( "TestCase" ) .( ClassObject ) .lookupAttribute ( "assertRaises" )
9288}
9389
9490/** Holds if expression `e` is in a `with` block that tests for exceptions being raised. */
Original file line number Diff line number Diff line change @@ -7,9 +7,8 @@ class ZopeInterfaceMethod extends PyFunctionObject {
77
88 /** Holds if this method belongs to a class that sub-classes `zope.interface.Interface` */
99 ZopeInterfaceMethod ( ) {
10- exists ( ModuleObject zope , Object interface , ClassObject owner |
11- zope .getAttribute ( "Interface" ) = interface and
12- zope .getName ( ) = "zope.interface" and
10+ exists ( Object interface , ClassObject owner |
11+ ModuleObject:: named ( "zope.interface" ) .getAttribute ( "Interface" ) = interface and
1312 owner .declaredAttribute ( _) = this and
1413 owner .getAnImproperSuperType ( ) .getABaseType ( ) = interface
1514 )
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ string mode_from_mode_object(Object obj) {
4040 result = "MULTILINE" or result = "DOTALL" or result = "UNICODE" or
4141 result = "VERBOSE"
4242 ) and
43- exists ( ModuleObject re | re . getName ( ) = "re" and re .getAttribute ( result ) = obj )
43+ ModuleObject:: named ( "re" ) .getAttribute ( result ) = obj
4444 or
4545 exists ( BinaryExpr be , Object sub | obj .getOrigin ( ) = be |
4646 be .getOp ( ) instanceof BitOr and
Original file line number Diff line number Diff line change @@ -33,10 +33,7 @@ private class ExpatParser extends TaintKind {
3333}
3434
3535private FunctionObject expatCreateParseFunction ( ) {
36- exists ( ModuleObject expat |
37- expat .getName ( ) = "xml.parsers.expat" and
38- result = expat .getAttribute ( "ParserCreate" )
39- )
36+ result = ModuleObject:: named ( "xml.parsers.expat" ) .getAttribute ( "ParserCreate" )
4037}
4138
4239private class ExpatCreateParser extends TaintSource {
Original file line number Diff line number Diff line change @@ -257,3 +257,12 @@ class PackageObject extends ModuleObject {
257257
258258}
259259
260+ /** Utility module for predicates relevant to the `ModuleObject` class. */
261+ module ModuleObject {
262+
263+ /** Gets a `ModuleObject` called `name`, if it exists. */
264+ ModuleObject named ( string name ) {
265+ result .getName ( ) = name
266+ }
267+
268+ }
You can’t perform that action at this time.
0 commit comments