Skip to content
Merged
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
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ extra-dependencies = [
"smolagents",
]
[tool.hatch.envs.types.scripts]
check = "mypy --install-types --non-interactive {args:src/cleanlab_codex tests}"
check = "mypy --strict --install-types --non-interactive {args:src/cleanlab_codex tests}"
[tool.hatch.metadata]
allow-direct-references = true

Expand All @@ -68,7 +68,7 @@ cov-combine = "coverage combine"
cov-report = "coverage report {env:COVERAGE_FAIL_UNDER}"

[tool.coverage.run]
source_pkgs = ["cleanlab_codex", "tests"]
source_pkgs = ["cleanlab_codex", "tests"]
branch = true
parallel = true
omit = [
Expand Down
2 changes: 1 addition & 1 deletion src/cleanlab_codex/utils/smolagents.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from smolagents import Tool # type: ignore


class CodexTool(Tool):
class CodexTool(Tool): # type: ignore[misc]
def __init__(
self,
query: Callable[[str], Optional[str]],
Expand Down
6 changes: 3 additions & 3 deletions tests/internal/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
DUMMY_API_KEY = "GP0FzPfA7wYy5L64luII2YaRT2JoSXkae7WEo7dH6Bw"


def test_is_access_key():
def test_is_access_key() -> None:
assert is_access_key(DUMMY_ACCESS_KEY)
assert not is_access_key(DUMMY_API_KEY)


def test_init_codex_client_access_key():
def test_init_codex_client_access_key() -> None:
with patch("cleanlab_codex.internal.utils._Codex", autospec=True) as mock_codex:
client = init_codex_client(DUMMY_ACCESS_KEY)
mock_codex.assert_called_once_with(access_key=DUMMY_ACCESS_KEY)
assert client is not None


def test_init_codex_client_api_key():
def test_init_codex_client_api_key() -> None:
with patch("cleanlab_codex.internal.utils._Codex", autospec=True) as mock_codex:
client = init_codex_client(DUMMY_API_KEY)
mock_codex.assert_called_once_with(api_key=DUMMY_API_KEY)
Expand Down
18 changes: 9 additions & 9 deletions tests/test_codex.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
DEFAULT_PROJECT_CONFIG = ProjectConfig()


def test_list_organizations(mock_client: MagicMock):
def test_list_organizations(mock_client: MagicMock) -> None:
mock_client.users.myself.organizations.list.return_value = UserOrganizationsSchema(
organizations=[
Organization(
Expand All @@ -40,7 +40,7 @@ def test_list_organizations(mock_client: MagicMock):
assert organizations[0].user_id == FAKE_USER_ID


def test_create_project(mock_client: MagicMock):
def test_create_project(mock_client: MagicMock) -> None:
mock_client.projects.create.return_value = ProjectReturnSchema(
id=FAKE_PROJECT_ID,
config=Config(),
Expand All @@ -62,7 +62,7 @@ def test_create_project(mock_client: MagicMock):
assert project_id == FAKE_PROJECT_ID


def test_add_entries(mock_client: MagicMock):
def test_add_entries(mock_client: MagicMock) -> None:
answered_entry_create = EntryCreate(
question="What is the capital of France?",
answer="Paris",
Expand All @@ -82,7 +82,7 @@ def test_add_entries(mock_client: MagicMock):
assert call.kwargs["answer"] == entry.get("answer")


def test_create_project_access_key(mock_client: MagicMock):
def test_create_project_access_key(mock_client: MagicMock) -> None:
codex = Codex("")
access_key_name = "Test Access Key"
access_key_description = "Test Access Key Description"
Expand All @@ -94,15 +94,15 @@ def test_create_project_access_key(mock_client: MagicMock):
)


def test_query_no_project_id(mock_client: MagicMock):
def test_query_no_project_id(mock_client: MagicMock) -> None:
mock_client.access_key = None
codex = Codex("")

with pytest.raises(MissingProjectIdError):
codex.query("What is the capital of France?")


def test_query_read_only(mock_client: MagicMock):
def test_query_read_only(mock_client: MagicMock) -> None:
mock_client.access_key = None
mock_client.projects.entries.query.return_value = None

Expand All @@ -115,7 +115,7 @@ def test_query_read_only(mock_client: MagicMock):
assert res == (None, None)


def test_query_question_found_fallback_answer(mock_client: MagicMock):
def test_query_question_found_fallback_answer(mock_client: MagicMock) -> None:
unanswered_entry = Entry(
id=str(uuid.uuid4()),
created_at=datetime.now(),
Expand All @@ -128,7 +128,7 @@ def test_query_question_found_fallback_answer(mock_client: MagicMock):
assert res == (None, unanswered_entry)


def test_query_question_not_found_fallback_answer(mock_client: MagicMock):
def test_query_question_not_found_fallback_answer(mock_client: MagicMock) -> None:
mock_client.projects.entries.query.return_value = None
mock_client.projects.entries.add_question.return_value = None

Expand All @@ -137,7 +137,7 @@ def test_query_question_not_found_fallback_answer(mock_client: MagicMock):
assert res == ("Paris", None)


def test_query_answer_found(mock_client: MagicMock):
def test_query_answer_found(mock_client: MagicMock) -> None:
answered_entry = Entry(
id=str(uuid.uuid4()),
created_at=datetime.now(),
Expand Down
6 changes: 3 additions & 3 deletions tests/test_codex_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from cleanlab_codex.codex_tool import CodexTool


def test_to_openai_tool(mock_client: MagicMock): # noqa: ARG001
def test_to_openai_tool(mock_client: MagicMock) -> None: # noqa: ARG001
tool = CodexTool.from_access_key("")
openai_tool = tool.to_openai_tool()
assert openai_tool.get("type") == "function"
Expand All @@ -16,7 +16,7 @@ def test_to_openai_tool(mock_client: MagicMock): # noqa: ARG001
assert openai_tool.get("function", {}).get("parameters", {}).get("type") == "object"


def test_to_llamaindex_tool(mock_client: MagicMock): # noqa: ARG001
def test_to_llamaindex_tool(mock_client: MagicMock) -> None: # noqa: ARG001
tool = CodexTool.from_access_key("")
llama_index_tool = tool.to_llamaindex_tool()
assert isinstance(llama_index_tool, FunctionTool)
Expand All @@ -26,7 +26,7 @@ def test_to_llamaindex_tool(mock_client: MagicMock): # noqa: ARG001


@pytest.mark.skipif(sys.version_info < (3, 10), reason="requires python3.10 or higher")
def test_to_smolagents_tool(mock_client: MagicMock): # noqa: ARG001
def test_to_smolagents_tool(mock_client: MagicMock) -> None: # noqa: ARG001
from smolagents import Tool # type: ignore

tool = CodexTool.from_access_key("")
Expand Down