Skip to content
Discussion options

You must be logged in to vote

Python's ast nodes know their children but not their parent. So codehound does one pass per file building a {id(child): parent} map (build_parents). Every check then walks upward through that map:

  • enclosing_function(node) climbs parents until it hits a FunctionDef/AsyncFunctionDef — that's how CH001 knows a call is inside an async def.
  • is_awaited(node) simply checks whether the node's parent is an ast.Await — that's how CH001 skips await client.post(...) and avoids false positives.

Building the map once is O(n) and keeps each check simple and precise.

Replies: 1 comment

Comment options

kratos0718
Jun 7, 2026
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by kratos0718
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant