Skip to content

Ignore imported initializer classes in script discovery#1509

Merged
hannahwestra25 merged 1 commit intomicrosoft:mainfrom
biefan:ignore-imported-script-initializers
Mar 20, 2026
Merged

Ignore imported initializer classes in script discovery#1509
hannahwestra25 merged 1 commit intomicrosoft:mainfrom
biefan:ignore-imported-script-initializers

Conversation

@biefan
Copy link
Copy Markdown
Contributor

@biefan biefan commented Mar 17, 2026

Summary

  • only instantiate initializer subclasses that are defined in the loaded script module itself
  • keep imported helper initializers available for reuse without auto-registering them as script initializers
  • add a regression test covering imported and local initializer classes in the same script

Problem

_load_initializers_from_scripts() currently instantiates every PyRITInitializer subclass found in a script module namespace, including classes that were only imported into that script. That makes script discovery load more initializers than the user actually defined in the file they passed in.

Validation

  • .venv/bin/pytest tests/unit/setup/test_initialization.py -q
  • .venv/bin/ruff check pyrit/setup/initialization.py tests/unit/setup/test_initialization.py

@hannahwestra25 hannahwestra25 self-assigned this Mar 20, 2026
@hannahwestra25 hannahwestra25 merged commit 8f93c2f into microsoft:main Mar 20, 2026
38 checks passed
riyosha pushed a commit to riyosha/PyRIT that referenced this pull request Mar 24, 2026
jbolor21 pushed a commit to jbolor21/jbolor-PyRIT that referenced this pull request Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants