File tree Expand file tree Collapse file tree
lib/semmle/python/dataflow/new/internal Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,6 +44,24 @@ private module Input implements InputSig<PythonDataFlow> {
4444 )
4545 }
4646
47+ predicate uniqueEnclosingCallableExclude ( Node n ) {
48+ // `CaptureNode`s miss enclosing calables in some cases.
49+ exists ( Function func |
50+ func = n .( CaptureNode ) .getSynthesizedCaptureNode ( ) .getEnclosingCallable ( )
51+ |
52+ // This can happen if `func` is a comprehension.
53+ // In that case, there is no associated DataFlowCallable.
54+ not exists ( func .getDefinition ( ) )
55+ or
56+ func .getADecorator ( ) .( Name ) .getId ( ) = "property"
57+ )
58+ or
59+ // We only have a selection of valid callables.
60+ // For instance, we do not have classes as `DataFlowCallable`s.
61+ not n .( CaptureNode ) .getSynthesizedCaptureNode ( ) .getEnclosingCallable ( ) instanceof Function and
62+ not n .( CaptureNode ) .getSynthesizedCaptureNode ( ) .getEnclosingCallable ( ) instanceof Module
63+ }
64+
4765 predicate uniqueCallEnclosingCallableExclude ( DataFlowCall call ) {
4866 not exists ( call .getLocation ( ) .getFile ( ) .getRelativePath ( ) )
4967 }
Original file line number Diff line number Diff line change @@ -40,6 +40,20 @@ private module Input implements InputSig<PythonDataFlow> {
4040 )
4141 }
4242
43+ predicate uniqueEnclosingCallableExclude ( Node n ) {
44+ // `CaptureNode`s miss enclosing calables in some cases.
45+ exists ( Function func |
46+ func = n .( CaptureNode ) .getSynthesizedCaptureNode ( ) .getEnclosingCallable ( )
47+ |
48+ // This can happen if `func` is a comprehension.
49+ // In that case, there is no associated DataFlowCallable.
50+ not exists ( func .getDefinition ( ) )
51+ )
52+ or
53+ // We do not have classes as `DataFlowCallable`s.
54+ n .( CaptureNode ) .getSynthesizedCaptureNode ( ) .getEnclosingCallable ( ) instanceof Class
55+ }
56+
4357 predicate uniqueCallEnclosingCallableExclude ( DataFlowCall call ) {
4458 not exists ( call .getLocation ( ) .getFile ( ) .getRelativePath ( ) )
4559 }
You can’t perform that action at this time.
0 commit comments