Skip to content

Commit 85fc9d0

Browse files
codeql: also suppress py/unused-import false positives
Same false-positive pattern as the prior ``py/ineffectual-statement`` exclusion — three cases CodeQL flags but isn't actually right about: - Forward-reference casts (``cast("FinishReason", x)``, ``cast("Checkpointer", capturing)``). The string argument isn't parsed by CodeQL but pyright resolves it; removing the import yields ``reportUndefinedVariable``. - Subscripted base classes (``class T(FanOutNode[State, State]):``) — the base class IS used. - Re-exports for public API. Pyright's ``reportUnusedImport`` covers the genuine cases at type-check time; the CodeQL rule duplicates with a worse FP rate.
1 parent bfb5838 commit 85fc9d0

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

.github/codeql/codeql-config.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,23 @@ name: "openarmature-python CodeQL config"
2828
query-filters:
2929
- exclude:
3030
id: py/ineffectual-statement
31+
# ``py/unused-import`` produces false positives on three patterns
32+
# this codebase relies on:
33+
#
34+
# - Forward-reference casts: ``cast("FinishReason", x)`` /
35+
# ``cast("Checkpointer", capturing)``. CodeQL doesn't look
36+
# inside the string argument; pyright's strict mode does, AND
37+
# raises ``reportUndefinedVariable`` if the name isn't in scope
38+
# (verified empirically — removing ``FinishReason`` from
39+
# ``openai.py``'s import yields the pyright error).
40+
# - Subscripted base classes: ``class _TracingFanOutNode(
41+
# FanOutNode[State, State]):``. The base class IS used; the
42+
# generic subscription happens at class-definition time.
43+
# - Re-exports for the public API surface (some submodule
44+
# ``__init__`` files import names solely to re-expose).
45+
#
46+
# Pyright's ``reportUnusedImport`` (default in strict mode) catches
47+
# the genuine unused-import cases without these false positives,
48+
# so dropping the CodeQL rule doesn't lose signal.
49+
- exclude:
50+
id: py/unused-import

0 commit comments

Comments
 (0)