From f4e302b3c0b439f6fc81ab1339d12d79eba57665 Mon Sep 17 00:00:00 2001 From: Richard Lundeen Date: Mon, 1 Jun 2026 09:23:48 -0700 Subject: [PATCH 1/2] MAINT: Deprecate MemoryExporter and export_conversations methods Adds DeprecationWarning emitted at runtime for: - pyrit.memory.MemoryExporter (via module __getattr__) - MemoryInterface.export_conversations - SQLiteMemory.export_conversations - SQLiteMemory.export_all_tables These will be removed in 0.15.0. This deprecation pass lands in 0.14.0 so that the breaking removal in PR #1856 can follow in the next release. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- pyrit/memory/__init__.py | 15 ++++++++++++++- pyrit/memory/memory_interface.py | 5 +++++ pyrit/memory/sqlite_memory.py | 11 +++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/pyrit/memory/__init__.py b/pyrit/memory/__init__.py index 9f10860130..5059d3d88b 100644 --- a/pyrit/memory/__init__.py +++ b/pyrit/memory/__init__.py @@ -10,7 +10,6 @@ from pyrit.memory.azure_sql_memory import AzureSQLMemory from pyrit.memory.central_memory import CentralMemory from pyrit.memory.memory_embedding import MemoryEmbedding -from pyrit.memory.memory_exporter import MemoryExporter from pyrit.memory.memory_interface import MemoryInterface from pyrit.memory.memory_models import AttackResultEntry, EmbeddingDataEntry, PromptMemoryEntry, SeedEntry from pyrit.memory.sqlite_memory import SQLiteMemory @@ -27,3 +26,17 @@ "PromptMemoryEntry", "SeedEntry", ] + + +def __getattr__(name: str): # noqa: N807 - module __getattr__ hook must use this name + if name == "MemoryExporter": + from pyrit.common.deprecation import print_deprecation_message + from pyrit.memory.memory_exporter import MemoryExporter + + print_deprecation_message( + old_item="pyrit.memory.MemoryExporter", + new_item="the pyrit.output module or direct serialization", + removed_in="0.15.0", + ) + return MemoryExporter + raise AttributeError(f"module {__name__!r} has no attribute {name!r}") diff --git a/pyrit/memory/memory_interface.py b/pyrit/memory/memory_interface.py index d5babd2cfd..1882d8b6cd 100644 --- a/pyrit/memory/memory_interface.py +++ b/pyrit/memory/memory_interface.py @@ -1591,6 +1591,11 @@ def export_conversations( Returns: Path: The path to the exported file. """ + print_deprecation_message( + old_item="MemoryInterface.export_conversations", + new_item="the pyrit.output module or direct serialization of get_message_pieces results", + removed_in="0.15.0", + ) data = self.get_message_pieces( attack_id=attack_id, conversation_id=conversation_id, diff --git a/pyrit/memory/sqlite_memory.py b/pyrit/memory/sqlite_memory.py index 8b63fb7ca8..acddacbc02 100644 --- a/pyrit/memory/sqlite_memory.py +++ b/pyrit/memory/sqlite_memory.py @@ -18,6 +18,7 @@ from sqlalchemy.pool import StaticPool from sqlalchemy.sql.expression import TextClause +from pyrit.common.deprecation import print_deprecation_message from pyrit.common.path import DB_DATA_PATH from pyrit.common.singleton import Singleton from pyrit.memory.memory_interface import MemoryInterface @@ -499,6 +500,11 @@ def export_conversations( Raises: ValueError: If the specified export format is not supported. """ + print_deprecation_message( + old_item="SQLiteMemory.export_conversations", + new_item="the pyrit.output module or direct serialization of get_message_pieces results", + removed_in="0.15.0", + ) # Import here to avoid circular import issues from pyrit.memory.memory_exporter import MemoryExporter @@ -585,6 +591,11 @@ def export_all_tables(self, *, export_type: str = "json") -> None: Args: export_type (str): The format to export the data in (defaults to "json"). """ + print_deprecation_message( + old_item="SQLiteMemory.export_all_tables", + new_item="the pyrit.output module or direct serialization of table query results", + removed_in="0.15.0", + ) table_models = self.get_all_table_models() for model in table_models: From 5da055dce23e77dffb87572f233e0619d151a834 Mon Sep 17 00:00:00 2001 From: Richard Lundeen Date: Mon, 1 Jun 2026 09:26:25 -0700 Subject: [PATCH 2/2] Fix ruff: add return type annotation to __getattr__ Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- pyrit/memory/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pyrit/memory/__init__.py b/pyrit/memory/__init__.py index 5059d3d88b..70acf720f5 100644 --- a/pyrit/memory/__init__.py +++ b/pyrit/memory/__init__.py @@ -7,6 +7,8 @@ This package defines the core `MemoryInterface` and concrete implementations for different storage backends. """ +from typing import Any + from pyrit.memory.azure_sql_memory import AzureSQLMemory from pyrit.memory.central_memory import CentralMemory from pyrit.memory.memory_embedding import MemoryEmbedding @@ -28,7 +30,7 @@ ] -def __getattr__(name: str): # noqa: N807 - module __getattr__ hook must use this name +def __getattr__(name: str) -> Any: # noqa: N807 - module __getattr__ hook must use this name if name == "MemoryExporter": from pyrit.common.deprecation import print_deprecation_message from pyrit.memory.memory_exporter import MemoryExporter