Skip to content

Commit 3e5f8fb

Browse files
committed
refactor(toolset): remove unused _matches_filter method
Remove the _matches_filter method from StackOneToolSet as it was never called in the source code (only used in tests). This reduces code complexity and improves test coverage percentage. The existing _filter_by_provider and _filter_by_action methods provide equivalent functionality and are actually used in fetch_tools.
1 parent 9d180ef commit 3e5f8fb

File tree

2 files changed

+0
-56
lines changed

2 files changed

+0
-56
lines changed

stackone_ai/toolset.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -253,34 +253,6 @@ def __init__(
253253
self.base_url = base_url or DEFAULT_BASE_URL
254254
self._account_ids: list[str] = []
255255

256-
def _matches_filter(self, tool_name: str, filter_pattern: str | list[str]) -> bool:
257-
"""Check if a tool name matches the filter pattern
258-
259-
Args:
260-
tool_name: Name of the tool to check
261-
filter_pattern: String or list of glob patterns to match against.
262-
Patterns starting with ! are treated as negative matches.
263-
264-
Returns:
265-
True if the tool name matches any positive pattern and no negative patterns,
266-
False otherwise
267-
"""
268-
patterns = [filter_pattern] if isinstance(filter_pattern, str) else filter_pattern
269-
270-
# Split into positive and negative patterns
271-
positive_patterns = [p for p in patterns if not p.startswith("!")]
272-
negative_patterns = [p[1:] for p in patterns if p.startswith("!")]
273-
274-
# If no positive patterns, treat as match all
275-
matches_positive = (
276-
any(fnmatch.fnmatch(tool_name, p) for p in positive_patterns) if positive_patterns else True
277-
)
278-
279-
# If any negative pattern matches, exclude the tool
280-
matches_negative = any(fnmatch.fnmatch(tool_name, p) for p in negative_patterns)
281-
282-
return matches_positive and not matches_negative
283-
284256
def set_accounts(self, account_ids: list[str]) -> StackOneToolSet:
285257
"""Set account IDs for filtering tools
286258

tests/test_toolset.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -45,31 +45,3 @@ def test_filter_by_action():
4545
# Test non-matching patterns
4646
assert not toolset._filter_by_action("workday_list_contacts", ["*_list_employees"])
4747
assert not toolset._filter_by_action("bamboohr_create_job", ["hibob_*"])
48-
49-
50-
def test_matches_filter_positive_patterns():
51-
"""Test _matches_filter with positive patterns"""
52-
toolset = StackOneToolSet(api_key="test_key")
53-
54-
# Single pattern
55-
assert toolset._matches_filter("hibob_list_employees", "hibob_*")
56-
assert toolset._matches_filter("bamboohr_create_job", "bamboohr_*")
57-
assert not toolset._matches_filter("workday_contacts", "hibob_*")
58-
59-
# Multiple patterns (OR logic)
60-
assert toolset._matches_filter("hibob_list_employees", ["hibob_*", "bamboohr_*"])
61-
assert toolset._matches_filter("bamboohr_create_job", ["hibob_*", "bamboohr_*"])
62-
assert not toolset._matches_filter("workday_contacts", ["hibob_*", "bamboohr_*"])
63-
64-
65-
def test_matches_filter_negative_patterns():
66-
"""Test _matches_filter with negative patterns (exclusion)"""
67-
toolset = StackOneToolSet(api_key="test_key")
68-
69-
# Negative pattern
70-
assert not toolset._matches_filter("hibob_delete_employee", ["hibob_*", "!hibob_delete_*"])
71-
assert toolset._matches_filter("hibob_list_employees", ["hibob_*", "!hibob_delete_*"])
72-
73-
# Only negative patterns (should match everything not excluded)
74-
assert not toolset._matches_filter("hibob_delete_employee", "!hibob_delete_*")
75-
assert toolset._matches_filter("hibob_list_employees", "!hibob_delete_*")

0 commit comments

Comments
 (0)