[FIX]: Fixup pyright Errors - #16
Merged
Merged
Conversation
3 tasks
Spencer Schoenberg (spencrr)
added a commit
that referenced
this pull request
Apr 17, 2026
…nfig (#9) ## Description Add project metadata, pyright, coverage config, and editorconfig ## Breaking changes <!-- Does this PR introduce breaking changes? If so, describe the impact and migration path. --> None ## Checklist - [ ] `pre-commit run --all-files` passes **No, see #16** - [ ] Tests added or updated for changes <!-- Please describe what tests were added or updated --> - [ ] Documentation updated
Spencer Schoenberg (spencrr)
force-pushed
the
spencrr/pyright-fixups
branch
from
April 17, 2026 09:19
91a6d39 to
45da61d
Compare
This was referenced Apr 17, 2026
Fix 13 pyright strict-mode errors across 7 files: reportUnnecessaryIsInstance (3): - response_contains.py: remove dead `not isinstance(target, Pattern)` guard — re.Pattern is not callable, so the branch is unreachable. Reorder to check callable() first. - drivers/__init__.py: remove redundant isinstance(value, PromptDriver) — type narrowing already exhausts the union after str/Request/list. - _session.py: suppress on ReportSink isinstance — intentional runtime guard at public API boundary for user-provided sinks. reportPrivateUsage (2): - Rename _coerce_driver to coerce_driver, extract to drivers/_utils.py. Update imports in attacks/__init__, probes/__init__. reportMissingTypeArgument (1): - response_contains.py: re.Pattern -> re.Pattern[str]. Also annotate tool_lines and source_lines as list[str] in manifest.py (reportUnknownVariableType).
Replace bare field(default_factory=dict) and field(default_factory=list) with typed lambdas (e.g. lambda: dict[str, Any]()) so pyright strict can infer generic type parameters. Fixes all reportUnknownVariableType errors in core data types.
Change **detail_predicates and **param_predicates from Any to Any | Callable[[Any], bool] in SideEffectOccurred and ToolCalled. Gives pyright visibility into the predicate union without breaking existing call sites.
- plugin.py: validate rampart_sinks fixture with cast(list[object]) + per-element isinstance narrowing; annotate user_sinks_raw as object - _session.py: remove redundant isinstance guard (caller now validates) - llm_bridge.py: cast PyRIT untyped return to Message, suppress remaining untyped member access at PyRIT boundary
Include tests/ in pyright analysis with a separate executionEnvironment that disables reportPrivateUsage, reportUnknownParameterType, reportUnknownMemberType, reportUnknownArgumentType, and reportUnknownVariableType. Uses extraPaths=["."] so tests can resolve rampart imports.
Replace mypy-style type: ignore codes (e.g. [arg-type], [misc]) with pyright-style pyright: ignore codes (e.g. [reportArgumentType], [reportCallIssue]) across all test files. Ensures suppressions are recognized by both pyright CLI and Pylance.
Spencer Schoenberg (spencrr)
force-pushed
the
spencrr/pyright-fixups
branch
from
April 20, 2026 23:46
45da61d to
adf473e
Compare
This was referenced Apr 21, 2026
Nina Chikanov (nina-msft)
approved these changes
Apr 21, 2026
Nina Chikanov (nina-msft)
left a comment
Contributor
There was a problem hiding this comment.
Some final comments on the utils func but the other changes look standard :)
Ran via `ruff check --preview --select CPY001`
Spencer Schoenberg (spencrr)
force-pushed
the
spencrr/pyright-fixups
branch
from
April 21, 2026 00:40
e3e56be to
cad5bc4
Compare
3 tasks
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.
Description
Fixes all the changes introduced by adding pyright in #9.
Breaking changes
None
Checklist
pre-commit run --all-filespasses