Repository navigation
MAINT: Enable the ty unsound-assignment rule with staged overrides (UA-0) #4407
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 | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -233,7 +233,6 @@ all = "error" | |||||||||||||||||||||||
| # Annotating those generics is real code work, so keep the rule deferred until | ||||||||||||||||||||||||
| # that numpy-generics debt is addressed. | ||||||||||||||||||||||||
| missing-type-argument = "ignore" | ||||||||||||||||||||||||
| unsound-assignment = "ignore" | ||||||||||||||||||||||||
| # unused-type-ignore-comment is environment-dependent: a `# type: ignore` | ||||||||||||||||||||||||
| # on an optional-dependency import (torch, playwright, etc.) is "used" when the | ||||||||||||||||||||||||
| # extra is not installed but "unused" once it is. CI installs `--extra all`, so | ||||||||||||||||||||||||
|
|
@@ -303,6 +302,76 @@ invalid-argument-type = "ignore" | |||||||||||||||||||||||
| invalid-method-override = "ignore" | ||||||||||||||||||||||||
| no-matching-overload = "ignore" | ||||||||||||||||||||||||
| unresolved-attribute = "ignore" | ||||||||||||||||||||||||
| # Tests read fixtures through `request.getfixturevalue(...)` and other Any-typed helpers into | ||||||||||||||||||||||||
| # annotated locals (32 findings). #4402 covers pyrit/ only, so the rule stays off for tests. | ||||||||||||||||||||||||
| unsound-assignment = "ignore" | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # SQLAlchemy 2.0 declarative models are written as `col: Mapped[T] = mapped_column(...)` | ||||||||||||||||||||||||
| # and `rel: Mapped[T] = relationship(...)`. Both calls are typed as returning Any-like | ||||||||||||||||||||||||
| # values, so unsound-assignment flags every column and relationship (196 findings with | ||||||||||||||||||||||||
| # one root cause). This is the documented idiom, not an unchecked boundary, and the | ||||||||||||||||||||||||
| # migrations depend on this file, so the rule stays off here permanently. | ||||||||||||||||||||||||
|
Comment on lines
+309
to
+313
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optional wording fix. On current That is
Suggested change
|
||||||||||||||||||||||||
| [[tool.ty.overrides]] | ||||||||||||||||||||||||
| include = ["pyrit/memory/memory_models.py"] | ||||||||||||||||||||||||
| [tool.ty.overrides.rules] | ||||||||||||||||||||||||
| unsound-assignment = "ignore" | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # TEMPORARY: files with unsound-assignment findings still to fix, tracked in | ||||||||||||||||||||||||
| # https://github.com/microsoft/PyRIT/issues/4402 (chunks UA-1 to UA-7). Each chunk's PR | ||||||||||||||||||||||||
| # fixes its findings and removes its files from this list; the PR that empties the list | ||||||||||||||||||||||||
| # deletes this override. Do not add files here: new code is checked by the rule. | ||||||||||||||||||||||||
| [[tool.ty.overrides]] | ||||||||||||||||||||||||
| include = [ | ||||||||||||||||||||||||
| "pyrit/auth/browser_session_copilot_authenticator.py", | ||||||||||||||||||||||||
| "pyrit/backend/middleware/runtime.py", | ||||||||||||||||||||||||
| "pyrit/backend/routes/targets.py", | ||||||||||||||||||||||||
| "pyrit/backend/routes/version.py", | ||||||||||||||||||||||||
| "pyrit/backend/services/attack_service.py", | ||||||||||||||||||||||||
| "pyrit/backend/services/finding_export.py", | ||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Required. #4134 added With this PR applied to current
Suggested change
|
||||||||||||||||||||||||
| "pyrit/backend/services/scenario_service.py", | ||||||||||||||||||||||||
| "pyrit/cli/api_client.py", | ||||||||||||||||||||||||
| "pyrit/cli/pyrit_scan.py", | ||||||||||||||||||||||||
| "pyrit/common/cli_helpers.py", | ||||||||||||||||||||||||
| "pyrit/common/yaml_loadable.py", | ||||||||||||||||||||||||
| "pyrit/converter/decomposition_converter.py", | ||||||||||||||||||||||||
| "pyrit/embedding/openai_text_embedding.py", | ||||||||||||||||||||||||
| "pyrit/executor/attack/multi_turn/tree_of_attacks.py", | ||||||||||||||||||||||||
| "pyrit/executor/attack/single_turn/many_shot_jailbreak.py", | ||||||||||||||||||||||||
| "pyrit/executor/promptgen/gcg/attack/base/attack_manager.py", | ||||||||||||||||||||||||
| "pyrit/executor/promptgen/gcg/attack/gcg/candidate_proposer.py", | ||||||||||||||||||||||||
| "pyrit/executor/promptgen/gcg/attack/gcg/gcg_attack.py", | ||||||||||||||||||||||||
| "pyrit/executor/promptgen/gcg/default_implementations.py", | ||||||||||||||||||||||||
| "pyrit/memory/alembic/env.py", | ||||||||||||||||||||||||
| "pyrit/memory/attack_analytics.py", | ||||||||||||||||||||||||
| "pyrit/memory/azure_sql_memory.py", | ||||||||||||||||||||||||
| "pyrit/memory/memory_interface.py", | ||||||||||||||||||||||||
| "pyrit/models/harm_category.py", | ||||||||||||||||||||||||
| "pyrit/models/messages/conversations.py", | ||||||||||||||||||||||||
| "pyrit/models/parameter.py", | ||||||||||||||||||||||||
| "pyrit/models/score/observation.py", | ||||||||||||||||||||||||
| "pyrit/models/score/scorable.py", | ||||||||||||||||||||||||
| "pyrit/prompt_normalizer/json_retry.py", | ||||||||||||||||||||||||
| "pyrit/prompt_normalizer/prompt_normalizer.py", | ||||||||||||||||||||||||
| "pyrit/prompt_target/azure_blob_storage_target.py", | ||||||||||||||||||||||||
| "pyrit/prompt_target/common/discover_target_capabilities.py", | ||||||||||||||||||||||||
| "pyrit/prompt_target/openai/openai_error_handling.py", | ||||||||||||||||||||||||
| "pyrit/prompt_target/openai/openai_response_target.py", | ||||||||||||||||||||||||
| "pyrit/prompt_target/prompt_shield_target.py", | ||||||||||||||||||||||||
| "pyrit/registry/components/target_registry.py", | ||||||||||||||||||||||||
| "pyrit/registry/registry_recipe_restore.py", | ||||||||||||||||||||||||
| "pyrit/registry/registry_recipe_rules.py", | ||||||||||||||||||||||||
| "pyrit/registry/registry_recipe_save.py", | ||||||||||||||||||||||||
| "pyrit/scenario/core/attack_technique_factory.py", | ||||||||||||||||||||||||
| "pyrit/scenario/scenarios/foundry/assert_policy.py", | ||||||||||||||||||||||||
| "pyrit/score/float_scale/local_violence_classifier_scorer.py", | ||||||||||||||||||||||||
| "pyrit/score/llm_scoring.py", | ||||||||||||||||||||||||
| "pyrit/score/observation/otel_execution_trace_source.py", | ||||||||||||||||||||||||
| "pyrit/score/scorer.py", | ||||||||||||||||||||||||
| "pyrit/score/scorer_prompt_validator.py", | ||||||||||||||||||||||||
| "pyrit/score/true_false/prompt_shield_scorer.py", | ||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||
| [tool.ty.overrides.rules] | ||||||||||||||||||||||||
| unsound-assignment = "ignore" | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| [tool.uv] | ||||||||||||||||||||||||
| constraint-dependencies = [ | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
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 is one of the two conflict spots: #4412 appended
missing-type-argument = "ignore"(with its own comment) at the same place. Keep both when you mergemain.Keeping the rule off for
tests/unitis the right call:make tycheckstests/unit, and #4402 only measuredpyrit/.Optional: drop the
(32 findings)count. It is 33 on currentmainand will keep drifting.