graphiti icon indicating copy to clipboard operation
graphiti copied to clipboard

Tests: Refactor and Fix Test Suite

Open evanmschultz opened this issue 8 months ago • 4 comments

Summary:

This PR focuses on streamlining our test suite and ensuring better consistency across test directories. Key Changes:

  • Moved the Anthropic integration test to the LLM client directory to align with the structure used in other tests.
  • Fixed malformed tests and resolved the issue with the mock LLM client naming.
  • Updated type hints and performed minor code cleaning to enhance code clarity and lint compliance.

Impact:

  • These changes aim to fix integration test failures and improve type hinting. Please review the changes, and let me know if any adjustments or further improvements are needed.

[!IMPORTANT] Refactor and fix test suite by moving tests, fixing issues, and updating type hints for consistency and clarity.

  • Test Structure:
    • Move test_anthropic_client_int.py from tests/integrations to tests/llm_client for consistency.
  • Test Fixes:
    • Fix malformed tests in test_anthropic_client.py and test_client.py.
    • Resolve mock LLM client naming issues in test_anthropic_client.py.
  • Type Hints and Code Cleaning:
    • Add type hints to test_anthropic_client.py and test_client.py.
    • Minor code cleaning for lint compliance in anthropic_client.py and client.py.

This description was created by Ellipsis for 40fc465048dbe9c09049afd7ca50c79abdc9d713. It will automatically update as commits are pushed.

evanmschultz avatar Apr 17 '25 17:04 evanmschultz

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

danielchalef avatar Apr 17 '25 17:04 danielchalef

I have read the CLA Document and I hereby sign the CLA

evanmschultz avatar Apr 17 '25 17:04 evanmschultz

Elipsis-Dev Pipe issue

When addressing the elipisis-dev comment about pipes in isinstance I get a ruff error:

Use `X | Y` in `isinstance` call instead of `(X, Y)`Ruff[UP038](https://docs.astral.sh/ruff/rules/non-pep604-isinstance)
make lint 
poetry run ruff check
graphiti_core/llm_client/client.py:43:8: UP038 Use `X | Y` in `isinstance` call instead of `(X, Y)`
   |
42 | def is_server_or_retry_error(exception: BaseException) -> bool:
43 |     if isinstance(exception, (RateLimitError, json.decoder.JSONDecodeError)):
   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP038
44 |         return True
   |
   = help: Convert to `X | Y`

Found 1 error.
No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option).
make: *** [lint] Error 1

How would you like me to deal with this?

Elipsis-Dev type: ignore issue

In regards to the type: ignore comment in anthropic_client.py, I am getting a pylance/pyright error in my IDE, Type of "input" is partially unknown\n Type of "input" is "dict[Unknown, Unknown]". The anthropic sdk defines the model as:

class ToolUseBlock(BaseModel):
    id: str

    input: object

    name: str

    type: Literal["tool_use"]

If I try any other method of solving this pyright error, for instance explicitly casting it as a ToolUseBlock, the issue is solved with the unknown attribute error, but then I get an error for unnecessary casting, because pyright already knows it is a ToolUseBlock. How would you like me to address this?

Thank you!

evanmschultz avatar Apr 17 '25 19:04 evanmschultz

recheck

evanmschultz avatar Apr 18 '25 00:04 evanmschultz