@@ -10,6 +10,8 @@ private import semmle.python.ApiGraphs
1010
1111/** Provides models for the `asyncpg` PyPI package. */
1212private module Asyncpg {
13+ private import semmle.python.internal.Awaited
14+
1315 /** A `ConectionPool` is created when the result of `asyncpg.create_pool()` is awaited. */
1416 API:: Node connectionPool ( ) {
1517 result = API:: moduleImport ( "asyncpg" ) .getMember ( "create_pool" ) .getReturn ( ) .getAwaited ( )
@@ -63,41 +65,6 @@ private module Asyncpg {
6365 }
6466 }
6567
66- /**
67- * Holds if `result` is the result of awaiting `awaitedValue`.
68- *
69- * Internal helper predicate to achieve the same as `.awaited()` does for API graphs,
70- * but sutiable for use with type-tracking.
71- */
72- pragma [ inline]
73- DataFlow:: Node awaited ( DataFlow:: Node awaitedValue ) {
74- // `await` x
75- // - `awaitedValue` is `x`
76- // - `result` is `await x`
77- exists ( Await await |
78- await .getValue ( ) = awaitedValue .asExpr ( ) and
79- result .asExpr ( ) = await
80- )
81- or
82- // `async for x in l`
83- // - `awaitedValue` is local source of `l`
84- // - `result` is `l`
85- exists ( AsyncFor asyncFor , DataFlow:: Node awaited |
86- asyncFor .getIter ( ) = awaited .asExpr ( ) and
87- awaited .getALocalSource ( ) = awaitedValue and
88- result .asExpr ( ) = asyncFor .getIter ( )
89- )
90- or
91- // `async with x as y`
92- // - `awaitedValue` is local source of `x`
93- // - `result` is `x` and `y`
94- exists ( AsyncWith asyncWith , DataFlow:: Node awaited |
95- awaited .asExpr ( ) = asyncWith .getContextExpr ( ) and
96- awaited .getALocalSource ( ) = awaitedValue and
97- result .asExpr ( ) in [ asyncWith .getContextExpr ( ) , asyncWith .getOptionalVars ( ) ]
98- )
99- }
100-
10168 /**
10269 * Provides models of the `PreparedStatement` class in `asyncpg`.
10370 * `PreparedStatement`s are created when the result of calling `prepare(query)` on a connection is awaited.
0 commit comments