Tests: Refactor and Fix Test Suite
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.pyfromtests/integrationstotests/llm_clientfor consistency.- Test Fixes:
- Fix malformed tests in
test_anthropic_client.pyandtest_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.pyandtest_client.py.- Minor code cleaning for lint compliance in
anthropic_client.pyandclient.py.This description was created by
for 40fc465048dbe9c09049afd7ca50c79abdc9d713. It will automatically update as commits are pushed.
All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.
I have read the CLA Document and I hereby sign the CLA
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!
recheck