Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
build
__pycache__*
.coverage*
coverage.xml
htmlcov/
.env
.venv
.mypy_cache
Expand Down
17 changes: 17 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,33 @@ Documentation = "https://strandsagents.com/"
[project.optional-dependencies]
dev = [
"commitizen>=4.4.0,<5.0.0",
"coverage>=7.0.0,<8.0.0",
"hatch>=1.0.0,<2.0.0",
"mypy>=0.981,<1.0.0",
"pre-commit>=3.2.0,<4.2.0",
"pytest>=8.0.0,<9.0.0",
"pytest-cov>=4.1.0,<5.0.0",
"pytest-asyncio>=1.1.0,<2.0.0",
"pytest-xdist>=3.0.0,<4.0.0",
"ruff>=0.4.4,<0.5.0",
"responses>=0.6.1,<1.0.0",
# Dependencies for all optional tools to enable full test coverage
"mem0ai>=0.1.104,<1.0.0",
"opensearch-py>=2.8.0,<3.0.0",
"nest-asyncio>=1.5.0,<2.0.0",
"playwright>=1.42.0,<2.0.0",
"bedrock-agentcore>=0.1.0",
"a2a-sdk[sql]>=0.2.16",
"feedparser>=6.0.10,<7.0.0",
"html2text>=2020.1.16,<2021.0.0",
"matplotlib>=3.5.0,<4.0.0",
"graphviz>=0.20.0,<1.0.0",
"networkx>=2.8.0,<4.0.0",
"diagrams>=0.23.0,<1.0.0",
"opencv-python>=4.5.0,<5.0.0",
"psutil>=5.8.0,<6.0.0",
"pyautogui>=0.9.53,<1.0.0",
"pytesseract>=0.3.8,<1.0.0",
]
docs = [
"sphinx>=5.0.0,<6.0.0",
Expand Down
15 changes: 15 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[tool:pytest]
testpaths = tests
python_files = test_*.py
python_classes = Test*
python_functions = test_*
addopts =
--tb=short
--no-cov
--disable-warnings
-q
collect_ignore = []
markers =
asyncio: marks tests as async
slow: marks tests as slow
integration: marks tests as integration tests
15 changes: 13 additions & 2 deletions src/strands_tools/python_repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,14 @@ class OutputCapture:
def __init__(self) -> None:
self.stdout = StringIO()
self.stderr = StringIO()
self._stdout = sys.stdout
self._stderr = sys.stderr
self._stdout = None
self._stderr = None

def __enter__(self) -> "OutputCapture":
# Store the current stdout/stderr (which might be another capture)
self._stdout = sys.stdout
self._stderr = sys.stderr
# Replace with our capture
sys.stdout = self.stdout
sys.stderr = self.stderr
return self
Expand All @@ -131,6 +135,7 @@ def __exit__(
exc_val: Optional[BaseException],
traceback: Optional[types.TracebackType],
) -> None:
# Restore the previous stdout/stderr
sys.stdout = self._stdout
sys.stderr = self._stderr

Expand Down Expand Up @@ -252,6 +257,12 @@ def get_user_objects(self) -> Dict[str, str]:

def clean_ansi(text: str) -> str:
"""Remove ANSI escape sequences from text."""
# ECMA-48 compliant ANSI escape sequence pattern
# Pattern breakdown:
# - \x1B: ESC character (0x1B)
# - (?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~]): Two alternatives:
# - [@-Z\\-_]: Fe sequences (two-character escape sequences)
# - \[[0-?]*[ -/]*[@-~]: CSI sequences with parameter/intermediate/final bytes
ansi_escape = re.compile(r"\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])")
return ansi_escape.sub("", text)

Expand Down
2 changes: 1 addition & 1 deletion src/strands_tools/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class WorkflowManager:

def __new__(cls, parent_agent: Optional[Any] = None):
if cls._instance is None:
cls._instance = super(WorkflowManager, cls).__new__(cls)
cls._instance = super().__new__(cls)
return cls._instance

def __init__(self, parent_agent: Optional[Any] = None):
Expand Down
Loading
Loading