Repository navigation
MAINT: Enable ty missing-type-argument rule - #4412
Merged
Roman Lutz (romanlutz) merged 2 commits intoNov 20, 2026
Merged
Roman Lutz (romanlutz) merged 2 commits into
Roman Lutz (romanlutz) merged 2 commits into
Conversation
Remove the `missing-type-argument = "ignore"` override so the rule runs under `[tool.ty.rules] all = "error"`, and parameterise the 14 bare generics it flags in pyrit/: - dict: cli/_config_reader, datasets multilingual_vulnerability_dataset, models/harm_category, models/score/score, score float_scale aggregator - os.PathLike: common/safe_extract (ZipSource and dest_dir) - sqlalchemy Select: four statement builders in memory/memory_interface - AttackStrategy: registry/components/attack_registry The rule was deferred because bare `np.ndarray` generics are flagged under numpy 2.2.x. uv.lock now pins numpy 2.4.6 for every supported Python (3.11 included), where ndarray's type parameters have defaults, so those annotations are no longer findings. ty 0.0.99 reports the same 14 findings on Python 3.11 and 3.14 before this change and none after. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Removing the global override exposes bare-generic annotations in unit tests to missing-type-argument errors, causing the CI make ty check to fail.
1 open issue
What changed in this PR
This PR enables ty’s missing-type-argument rule and parameterizes 14 bare generics in PyRIT’s production code.
Changes:
- Removes the global suppression for
missing-type-argument. - Adds explicit type arguments for dictionaries, paths, SQLAlchemy statements, and attack strategies.
- Updates the score identifier serializer’s declared return type.
| File | Description |
|---|---|
pyrit/score/float_scale/float_scale_score_aggregator.py |
Types aggregator metadata and updates its docstring. |
pyrit/registry/components/attack_registry.py |
Parameterizes heterogeneous attack strategy types. |
pyrit/models/score/score.py |
Specifies the serializer’s dictionary return type. |
pyrit/models/harm_category.py |
Types the parsed YAML mapping. |
pyrit/memory/memory_interface.py |
Adds type arguments to four query builders. |
pyrit/datasets/seed_datasets/remote/multilingual_vulnerability_dataset.py |
Types dataset rows as string dictionaries. |
pyrit/common/safe_extract.py |
Specifies string-based path-like inputs. |
pyrit/cli/_config_reader.py |
Types configuration mappings and updates the docstring. |
pyproject.toml |
Removes the missing-type-argument suppression. |
Review effort: Balanced
CI's `make ty` checks tests/unit as well as pyrit/. Enabling the rule repo-wide surfaced 318 bare generics in tests/unit, failing that step. Add the rule to the existing tests/unit override so it is enforced for pyrit/ only, matching how other strict rules are relaxed for tests. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Richard Lundeen (richlundeen)
approved these changes
Nov 19, 2026
Richard Lundeen (richlundeen)
left a comment
Contributor
There was a problem hiding this comment.
Automated review completed. No blocking concerns remain. This review records source coverage; merging is handled separately.
Roman Lutz (romanlutz)
deleted the
claude/ty-missing-type-argument-26c5c6
branch
November 20, 2026 07:05
Roman Lutz (romanlutz)
added a commit
to mss06s/PyRIT
that referenced
this pull request
Nov 21, 2026
Resolve the pyproject.toml conflict with microsoft#4412 by keeping both sides: the global unsound-assignment ignore stays deleted, and the tests/unit override keeps microsoft#4412's missing-type-argument line followed by this PR's block. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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
Turn on ty's
missing-type-argumentrule forpyrit/by removing its"ignore"override inpyproject.tomland parameterising the 14 bare generics it flags. The rule stays relaxed fortests/unit/**through the existing unit-test override (318 bare generics there), somake tyremains clean.dict(5):cli/_config_reader.py,datasets/.../multilingual_vulnerability_dataset.py,models/harm_category.py,models/score/score.py,score/float_scale/float_scale_score_aggregator.py. Each takes the type its callers already use (dict[str, str]for a dataset row,dict[str, str | int | float]for score metadata,dict[str, Any]for parsed YAML).os.PathLike(2):common/safe_extract.pynow saysos.PathLike[str], which is whatzipfile.ZipFileandPathaccept.Select(4): the statement builders inmemory/memory_interface.py. The message-page builder isSelect[PromptMemoryEntry]. The three scenario-delta builders areSelect[*tuple[Any, ...]]: the projection has 25 columns, SQLAlchemy only types the first 10, and callers read rows through.mappings().AttackStrategy(3):registry/components/attack_registry.pyusesAttackStrategy[Any, Any], the spelling already used for heterogeneous strategies inattack_technique_factory.py.Notes for reviewers:
np.ndarrayis flagged under numpy 2.2.x.uv.locknow pins numpy 2.4.6 for every supported Python, 3.11 included, and therendarray's type parameters have defaults. ty 0.0.99 reports the same 14 findings on Python 3.11 and 3.14 before this change and none after. Thenp.ndarrayannotations are untouched; they would be flagged again (42 sites) only if the lock moved back below numpy 2.4.models/score/score.pythe flaggeddictis the argumentPlainSerializer(..., return_type=dict | None), nowdict[str, Any] | Noneto matchComponentIdentifier's serializer. Pydantic's internal key serializer for that field goes fromanytostr; the JSON schemas ofScore,MessagePieceandConversationand a sampleScoredump are byte-identical before and after.🤖 Generated with Claude Code