Skip to content

Commit 62a9924

Browse files
committed
Python: Update QLDoc
1 parent 2bf4c32 commit 62a9924

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowDispatch.qll

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,15 @@ class ExtractedReturnNode extends ReturnNode, CfgNode {
16171617
override ReturnKind getKind() { any() }
16181618
}
16191619

1620-
/** A data flow node that represents a value returned by a callable. */
1620+
/**
1621+
* A data flow node that represents the value yielded by a callable with a
1622+
* `contextlib.contextmanager` decorator. We treat this as a normal return, which makes
1623+
* things just work when used in a `with` statement -- technically calling the function
1624+
* directly will give you a `contextlib._GeneratorContextManager` instance, so it's a
1625+
* slight workaround solution.
1626+
*
1627+
* See https://docs.python.org/3/library/contextlib.html#contextlib.contextmanager
1628+
*/
16211629
class YieldNodeInContextManagerFunction extends ReturnNode, CfgNode {
16221630
YieldNodeInContextManagerFunction() {
16231631
hasContextmanagerDecorator(node.getScope()) and

0 commit comments

Comments
 (0)