Repository navigation
Conversation
Prevent ineffectual-statement false positives when awaiting a task or coroutine without assigning its returned value. Add regression cases for both forms. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f0800d30-e4f9-463c-a0d8-660fe1aceaf1
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the change to treat Python await expressions as side-effecting.
No open issues 🎉
What changed in this PR
This PR updates Python’s side-effect analysis so py/ineffectual-statement no longer flags await expressions merely because their results are discarded.
Changes:
- Mark
Awaitexpressions as side-effecting, consistent withyieldandyield from. - Add regression cases for awaiting value-returning tasks and coroutines.
- Document the analysis change in a library change note.
| File | Description |
|---|---|
python/ql/test/query-tests/Statements/no_effect/await_task.py |
Adds task and coroutine regression cases. |
python/ql/lib/semmle/python/Exprs.qll |
Makes Await.hasSideEffects() always hold. |
python/ql/lib/change-notes/2026-11-05-await-side-effects.md |
Documents the false-positive fix. |
Review effort: Balanced (auto)
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Awaitexpressions as side-effecting, consistent withyieldandyield from.py/ineffectual-statementfrom flagging an awaited task or coroutine merely because its returned value is discarded.Example false positive: microsoft/agent-framework#8662 (comment)
Validation
python/ql/test/query-tests/Statements/no_effectpass using CodeQL CLI 2.27.4 in a Linux ARM64 Docker container.codeql query format --check-onlyandgit diff --checkpass.