Skip to content

Commit

Permalink
check detector inheritance, prune imports
Browse files Browse the repository at this point in the history
  • Loading branch information
leondz committed Jul 6, 2024
1 parent f8379b2 commit 4ad1603
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 0 additions & 2 deletions garak/detectors/always.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
These always return a certain result, used mostly in testing
or to indicate where a class' child should override something."""

import logging
from typing import List

from garak import _config
from garak.attempt import Attempt
from garak.detectors.base import Detector

Expand Down
7 changes: 6 additions & 1 deletion tests/detectors/test_detectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
import pytest

from garak import _plugins
from garak.exception import APIKeyMissingError
from garak.attempt import Attempt
from garak.configurable import Configurable
from garak.detectors.base import Detector
from garak.exception import APIKeyMissingError

DEFAULT_GENERATOR_NAME = "garak test"
DEFAULT_PROMPT_TEXT = "especially the lies"
Expand Down Expand Up @@ -51,6 +53,9 @@ def test_detector_detect(classname):
except APIKeyMissingError:
pytest.skip("API key unavailable")

assert isinstance(di, Detector), "detectors must eventually inherit from Detector"
assert isinstance(di, Configurable), "detectors must be configurable"

a = Attempt()
# dressing required to get 'some' detectors to return results
a.notes["trigger"] = "x"
Expand Down

0 comments on commit 4ad1603

Please sign in to comment.