-
Notifications
You must be signed in to change notification settings - Fork 51
[FIX]: Fixup pyright Errors #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
345e4be
fix(pyright): resolve strict-mode errors — wave 1
spencrr 7b64286
fix(types): use typed default_factory for pyright strict
spencrr d400038
fix(evaluators): type predicate kwargs as str | Callable
spencrr a07ba1f
fix(plugin,pyrit): resolve pyright errors at third-party boundaries
spencrr 0e209dd
build: add tests/ to pyright with relaxed execution environment
spencrr 67c24be
fix(tests): align type: ignore comments with pyright rules
spencrr 511d447
fix: ruff
spencrr d44d364
cleanup: some reverts, test fixes
spencrr 27c08cc
fixup module doc comment
spencrr adf473e
fixup comment
spencrr cad5bc4
fixup copyright
spencrr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,46 +1,8 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT license. | ||
|
|
||
|
spencrr marked this conversation as resolved.
|
||
| """Driver implementations. | ||
| """Driver implementations.""" | ||
|
|
||
| Re-exports StaticDriver and provides the _coerce_driver helper | ||
| for ergonomic prompt/driver coercion. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from rampart.core.prompt_driver import PromptDriver | ||
| from rampart.core.types import Request | ||
| from rampart.drivers.static import StaticDriver | ||
|
|
||
| __all__ = ["StaticDriver", "_coerce_driver"] | ||
|
|
||
|
|
||
| def _coerce_driver( | ||
| value: str | list[str] | Request | list[Request] | PromptDriver, | ||
| ) -> PromptDriver: | ||
| """Coerce a string, Request, or list into a PromptDriver. | ||
|
|
||
| Args: | ||
| value: A single prompt string, a list of prompt strings, | ||
| a single Request, a list of Requests, or an existing | ||
| PromptDriver. | ||
|
|
||
| Returns: | ||
| PromptDriver: A driver wrapping the input. | ||
| """ | ||
| if isinstance(value, str): | ||
| return StaticDriver(prompts=[value]) | ||
| if isinstance(value, Request): | ||
| return StaticDriver(prompts=[value]) | ||
| if isinstance(value, list): | ||
| return StaticDriver(prompts=value) | ||
| if isinstance(value, PromptDriver): | ||
| return value | ||
| msg = ( | ||
| f"Cannot coerce {type(value).__name__} to PromptDriver. " | ||
| f"Expected str, list[str], Request, list[Request], or PromptDriver." | ||
| ) | ||
| raise TypeError( | ||
| msg, | ||
| ) | ||
| __all__ = ["StaticDriver"] | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT license. | ||
|
|
||
| from rampart.core.prompt_driver import PromptDriver | ||
|
spencrr marked this conversation as resolved.
|
||
| from rampart.core.types import Request | ||
| from rampart.drivers.static import StaticDriver | ||
|
|
||
|
|
||
| def coerce_driver( | ||
| value: str | list[str] | Request | list[Request] | PromptDriver, | ||
| ) -> PromptDriver: | ||
| """Coerce a string, Request, or list into a PromptDriver. | ||
|
|
||
| Args: | ||
| value: A single prompt string, a list of prompt strings, | ||
| a single Request, a list of Requests, or an existing | ||
| PromptDriver. | ||
|
|
||
| Returns: | ||
| PromptDriver: A driver wrapping the input. | ||
| """ | ||
| if isinstance(value, str): | ||
| return StaticDriver(prompts=[value]) | ||
| if isinstance(value, Request): | ||
| return StaticDriver(prompts=[value]) | ||
| if isinstance(value, list): | ||
|
spencrr marked this conversation as resolved.
|
||
| return StaticDriver(prompts=value) | ||
| return value | ||
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.