-
Notifications
You must be signed in to change notification settings - Fork 679
MAINT Enable ruff PGH rule for pygrep-hooks linting #1416
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -91,7 +91,7 @@ def __init__( | |||||||||
| """ | ||||||||||
| self.id = id if id else uuid4() | ||||||||||
|
|
||||||||||
| if role not in ChatMessageRole.__args__: # type: ignore | ||||||||||
| if role not in ChatMessageRole.__args__: # type: ignore[attr-defined] | ||||||||||
| raise ValueError(f"Role {role} is not a valid role.") | ||||||||||
|
|
||||||||||
| self._role: ChatMessageRole = role | ||||||||||
|
|
@@ -251,14 +251,20 @@ def role(self, value: ChatMessageRole) -> None: | |||||||||
| ValueError: If the role is not a valid ChatMessageRole. | ||||||||||
|
|
||||||||||
| """ | ||||||||||
| if value not in ChatMessageRole.__args__: # type: ignore | ||||||||||
| if value not in ChatMessageRole.__args__: # type: ignore[attr-defined] | ||||||||||
| raise ValueError(f"Role {value} is not a valid role.") | ||||||||||
| self._role = value | ||||||||||
|
|
||||||||||
| def to_message(self) -> Message: # type: ignore # noqa F821 | ||||||||||
| def to_message(self) -> Message: # type: ignore[name-defined] # noqa: F821 | ||||||||||
| """ | ||||||||||
| Convert this message piece into a Message. | ||||||||||
|
|
||||||||||
| Returns: | ||||||||||
| Message: A Message containing this piece. | ||||||||||
| """ | ||||||||||
|
||||||||||
| """ | |
| """ | |
| # Local import is required to avoid a circular dependency because | |
| # pyrit.models.message imports MessagePiece. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -196,7 +196,7 @@ async def _convert_word_level_async(self, *, prompt: str) -> ConverterResult: | |
| words = prompt.split(self._word_separator) | ||
|
|
||
| # Get selected word indices | ||
| selected_indices = self._selection_strategy.select_words(words=words) # type: ignore | ||
| selected_indices = self._selection_strategy.select_words(words=words) # type: ignore[attr-defined] | ||
|
|
||
| # If no words selected, return original prompt | ||
|
Comment on lines
196
to
201
|
||
| if not selected_indices: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,13 +72,13 @@ def import_scores_from_csv(self, csv_file_path: Path) -> list[MessagePiece]: | |
| labels = json.loads(labels_str) if labels_str else None | ||
|
|
||
| message_piece = MessagePiece( | ||
| role=row["role"], # type: ignore | ||
| role=row["role"], # type: ignore[arg-type] | ||
| original_value=row["value"], | ||
| original_value_data_type=row.get["data_type", None], # type: ignore | ||
| original_value_data_type=row.get("data_type", None), # type: ignore[arg-type] | ||
| conversation_id=row.get("conversation_id", None), | ||
| sequence=int(sequence_str) if sequence_str else None, | ||
| labels=labels, | ||
| response_error=row.get("response_error", None), # type: ignore | ||
| response_error=row.get("response_error", None), # type: ignore[arg-type] | ||
| prompt_target_identifier=self.get_identifier(), | ||
|
Comment on lines
74
to
82
|
||
| ) | ||
| message_pieces.append(message_piece) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -438,7 +438,7 @@ def _get_scorer(self, subharm: Optional[str] = None) -> FloatScaleThresholdScore | |
| ) | ||
|
|
||
| # Wrap with conversation scorer to evaluate full conversation history | ||
| conversation_scorer: FloatScaleScorer = create_conversation_scorer(scorer=psych_scorer) # type: ignore | ||
| conversation_scorer: FloatScaleScorer = create_conversation_scorer(scorer=psych_scorer) # type: ignore[assignment] | ||
|
|
||
|
Comment on lines
440
to
442
|
||
| # Wrap with threshold scorer | ||
| # threshold=1.0 means only raw score 5 counts as attack success (extremely harmful) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
# type: ignore[union-attr]on the return statement is unlikely to match the actual mypy error under--strict(commonlyno-any-returnhere, sincejson.loads(...)yieldsAny). If the ignore code doesn’t match, mypy will both report the real error and treat this ignore as unused. Prefer typing/casting the parsed JSON todict[str, Any](or update the ignore to the correct mypy error code).