ruff formatting

This commit is contained in:
hajdul88 2025-08-13 15:15:39 +02:00
parent 68327d3ab9
commit da40365932
13 changed files with 30 additions and 18 deletions

View file

@ -9,5 +9,5 @@ from .exceptions import (
DocumentNotFoundError,
DatasetNotFoundError,
DataNotFoundError,
DocumentSubgraphNotFoundError
DocumentSubgraphNotFoundError,
)

View file

@ -1,7 +1,4 @@
from cognee.exceptions import (
CogneeConfigurationError,
CogneeValidationError
)
from cognee.exceptions import CogneeConfigurationError, CogneeValidationError
from fastapi import status
@ -15,6 +12,7 @@ class InvalidConfigAttributeError(CogneeConfigurationError):
message = f"'{attribute}' is not a valid attribute of the configuration."
super().__init__(message, name, status_code)
class DocumentNotFoundError(CogneeValidationError):
def __init__(
self,
@ -24,6 +22,7 @@ class DocumentNotFoundError(CogneeValidationError):
):
super().__init__(message, name, status_code)
class DatasetNotFoundError(CogneeValidationError):
def __init__(
self,
@ -33,6 +32,7 @@ class DatasetNotFoundError(CogneeValidationError):
):
super().__init__(message, name, status_code)
class DataNotFoundError(CogneeValidationError):
def __init__(
self,
@ -42,6 +42,7 @@ class DataNotFoundError(CogneeValidationError):
):
super().__init__(message, name, status_code)
class DocumentSubgraphNotFoundError(CogneeValidationError):
def __init__(
self,

View file

@ -89,4 +89,3 @@ class CogneeTransientError(CogneeApiError):
log_level="ERROR",
):
super().__init__(message, name, status_code, log, log_level)

View file

@ -4,6 +4,4 @@ Custom exceptions for the Cognee API.
This module defines a set of exceptions for handling various data errors
"""
from .exceptions import (
KeywordExtractionError
)
from .exceptions import KeywordExtractionError

View file

@ -10,5 +10,5 @@ from .exceptions import (
DatabaseNotCreatedError,
EmbeddingException,
MissingQueryParameterError,
MutuallyExclusiveQueryParametersError
MutuallyExclusiveQueryParametersError,
)

View file

@ -103,11 +103,13 @@ class EmbeddingException(CogneeConfigurationError):
):
super().__init__(message, name, status_code)
class MissingQueryParameterError(CogneeValidationError):
"""
Raised when neither 'query_text' nor 'query_vector' is provided,
and at least one is required to perform the operation.
"""
def __init__(
self,
name: str = "MissingQueryParameterError",
@ -116,17 +118,17 @@ class MissingQueryParameterError(CogneeValidationError):
message = "One of query_text or query_vector must be provided!"
super().__init__(message, name, status_code)
class MutuallyExclusiveQueryParametersError(CogneeValidationError):
"""
Raised when both 'text' and 'embedding' are provided to the search function,
but only one type of input is allowed at a time.
"""
def __init__(
self,
name: str = "MutuallyExclusiveQueryParametersError",
status_code: int = status.HTTP_400_BAD_REQUEST,
):
message = (
"The search function accepts either text or embedding as input, but not both."
)
message = "The search function accepts either text or embedding as input, but not both."
super().__init__(message, name, status_code)

View file

@ -9,6 +9,7 @@ class LLMAPIKeyNotSetError(CogneeValidationError):
"""
Raised when the LLM API key is not set in the configuration.
"""
def __init__(self, message: str = "LLM API key is not set."):
super().__init__(message=message, name="LLMAPIKeyNotSetError")
@ -17,10 +18,12 @@ class UnsupportedLLMProviderError(CogneeValidationError):
"""
Raised when an unsupported LLM provider is specified in the configuration.
"""
def __init__(self, provider: str):
message = f"Unsupported LLM provider: {provider}"
super().__init__(message=message, name="UnsupportedLLMProviderError")
class MissingSystemPromptPathError(CogneeValidationError):
def __init__(
self,

View file

@ -11,7 +11,10 @@ from cognee.infrastructure.llm.LLMGateway import LLMGateway
from cognee.infrastructure.llm.structured_output_framework.litellm_instructor.llm.llm_interface import (
LLMInterface,
)
from cognee.infrastructure.llm.exceptions import ContentPolicyFilterError, MissingSystemPromptPathError
from cognee.infrastructure.llm.exceptions import (
ContentPolicyFilterError,
MissingSystemPromptPathError,
)
from cognee.infrastructure.files.utils.open_data_file import open_data_file
from cognee.infrastructure.llm.structured_output_framework.litellm_instructor.llm.rate_limiter import (
rate_limit_async,

View file

@ -2,7 +2,11 @@ import time
from cognee.shared.logging_utils import get_logger
from typing import List, Dict, Union, Optional, Type
from cognee.modules.graph.exceptions import EntityNotFoundError, EntityAlreadyExistsError, InvalidDimensionsError
from cognee.modules.graph.exceptions import (
EntityNotFoundError,
EntityAlreadyExistsError,
InvalidDimensionsError,
)
from cognee.infrastructure.databases.graph.graph_db_interface import GraphDBInterface
from cognee.modules.graph.cognee_graph.CogneeGraphElements import Node, Edge
from cognee.modules.graph.cognee_graph.CogneeAbstractGraph import CogneeAbstractGraph

View file

@ -2,6 +2,7 @@ import numpy as np
from typing import List, Dict, Optional, Any, Union
from cognee.modules.graph.exceptions import InvalidDimensionsError, DimensionOutOfRangeError
class Node:
"""
Represents a node in a graph.

View file

@ -25,6 +25,7 @@ class EntityAlreadyExistsError(CogneeValidationError):
):
super().__init__(message, name, status_code)
class InvalidDimensionsError(CogneeValidationError):
def __init__(
self,
@ -34,6 +35,7 @@ class InvalidDimensionsError(CogneeValidationError):
message = "Dimensions must be positive integers."
super().__init__(message, name, status_code)
class DimensionOutOfRangeError(CogneeValidationError):
def __init__(
self,

View file

@ -4,6 +4,4 @@ Custom exceptions for the Cognee API.
This module defines a set of exceptions for handling various data errors
"""
from .exceptions import (
UnsupportedSearchTypeError
)
from .exceptions import UnsupportedSearchTypeError

View file

@ -4,6 +4,7 @@ import pytest
from cognee.modules.graph.cognee_graph.CogneeGraphElements import Edge, Node
from cognee.modules.graph.exceptions import InvalidDimensionsError, DimensionOutOfRangeError
def test_node_initialization():
"""Test that a Node is initialized correctly."""
node = Node("node1", {"attr1": "value1"}, dimension=2)