Commit 929d398
FIX: Move AttackStrategy import to TYPE_CHECKING to break circular import
PR #1881 (Pydantic identifiers refactor) re-merged with this PR's
compute_inner_attack_eval_hash addition and hoisted
rom pyrit.executor.attack.core.attack_strategy import AttackStrategy
to module level. That import triggers a cycle through
`pyrit.executor.attack` -> `pyrit.message_normalizer` ->
`pyrit.common.data_url_converter` -> `pyrit.models`, which fails
because `pyrit.models` is still being initialised at that point
(DataTypeSerializer is not yet defined).
`from __future__ import annotations` is already enabled, so the
type annotation `attack: AttackStrategy` works as a string. Moving
the import inside `if TYPE_CHECKING:` restores the original lazy
boundary and unblocks CI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 115d1f7 commit 929d398
2 files changed
Lines changed: 8 additions & 2 deletions
File tree
- pyrit/models/identifiers
- tests/unit/models/identifiers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | 30 | | |
32 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
585 | 585 | | |
586 | 586 | | |
587 | 587 | | |
| 588 | + | |
588 | 589 | | |
589 | 590 | | |
590 | 591 | | |
| |||
654 | 655 | | |
655 | 656 | | |
656 | 657 | | |
| 658 | + | |
| 659 | + | |
657 | 660 | | |
658 | 661 | | |
659 | 662 | | |
| |||
864 | 867 | | |
865 | 868 | | |
866 | 869 | | |
| 870 | + | |
867 | 871 | | |
868 | 872 | | |
869 | 873 | | |
| |||
0 commit comments