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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 4 additions & 2 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ jobs:
python-version: "3.11"
cache: 'pip' # caching pip dependencies
- run: pip install -r requirements-devel.txt
- name: "Black"
run: black --check weaviate test mock_tests integration
- name: "Ruff lint"
run: ruff check weaviate test mock_tests integration
- name: "Ruff format"
run: ruff format --diff weaviate test mock_tests integration
- name: "Flake 8"
run: flake8 weaviate test mock_tests integration
- name: "Check release for pypi"
Expand Down
32 changes: 15 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,16 @@ repos:
language: system
entry: ./tools/stubs_regen.sh

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.10.0
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.11.7
hooks:
- id: black
language_version: python3.12

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: no-commit-to-branch
- id: trailing-whitespace

- repo: https://github.com/myint/autoflake
rev: v2.2.1 # autoflake v2.2.1 is the latest version that supports Python 3.12
hooks:
- id: autoflake
args: [--in-place, --remove-all-unused-imports, --exclude=weaviate/proto/*]

# Run the linter.
- id: ruff
args: [ weaviate, integration, test, mock_tests, journey_tests, --fix ]
# Run the formatter.
- id: ruff-format
args: [ weaviate, integration, test, mock_tests, journey_tests ]

- repo: https://github.com/PyCQA/flake8
rev: 7.1.0
Expand All @@ -43,6 +35,12 @@ repos:
'pydoclint==0.6.5',
]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: no-commit-to-branch
- id: trailing-whitespace

- repo: local
hooks:
- id: pyright
Expand Down
20 changes: 10 additions & 10 deletions integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
from typing import (
Any,
AsyncGenerator,
Optional,
List,
Dict,
Generator,
List,
Optional,
Protocol,
Type,
Dict,
Tuple,
Type,
Union,
)

Expand All @@ -19,17 +19,17 @@
import weaviate
from weaviate.collections import Collection, CollectionAsync
from weaviate.collections.classes.config import (
Configure,
DataType,
Property,
_VectorizerConfigCreate,
_GenerativeProvider,
_InvertedIndexConfigCreate,
_MultiTenancyConfigCreate,
_ReferencePropertyBase,
Configure,
_GenerativeProvider,
_ReplicationConfigCreate,
DataType,
_MultiTenancyConfigCreate,
_VectorIndexConfigCreate,
_RerankerProvider,
_VectorIndexConfigCreate,
_VectorizerConfigCreate,
)
from weaviate.collections.classes.config_named_vectors import _NamedVectorConfigCreate
from weaviate.collections.classes.types import Properties
Expand Down
4 changes: 2 additions & 2 deletions integration/test_backup_v4.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import datetime
import pathlib
import time
from typing import Generator, List, Union, Optional
from typing import Generator, List, Optional, Union

import pytest

Expand All @@ -16,8 +16,8 @@
)
from weaviate.collections.classes.config import DataType, Property, ReferenceProperty
from weaviate.exceptions import (
UnexpectedStatusCodeException,
BackupFailedException,
UnexpectedStatusCodeException,
)

pytestmark = pytest.mark.xdist_group(name="backup")
Expand Down
6 changes: 3 additions & 3 deletions integration/test_batch_v4.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import concurrent.futures
import uuid
from dataclasses import dataclass
from typing import Generator, List, Optional, Protocol, Tuple, Callable
from typing import Callable, Generator, List, Optional, Protocol, Tuple

import pytest
from _pytest.fixtures import SubRequest

import weaviate
from weaviate import BatchClient, ClientBatchingContextManager
import weaviate.classes as wvc
from integration.conftest import _sanitize_collection_name
from weaviate import BatchClient, ClientBatchingContextManager
from weaviate.collections.classes.batch import Shard
from weaviate.collections.classes.config import (
Configure,
Expand All @@ -19,8 +19,8 @@
)
from weaviate.collections.classes.grpc import QueryReference
from weaviate.collections.classes.internal import (
_CrossReference,
ReferenceToMulti,
_CrossReference,
)
from weaviate.collections.classes.tenants import Tenant
from weaviate.types import UUID, VECTORS
Expand Down
7 changes: 3 additions & 4 deletions integration/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@
from _pytest.fixtures import SubRequest

import weaviate
import weaviate.classes as wvc
from weaviate.collections import Collection
from weaviate.collections.classes.config import (
Configure,
_CollectionConfig,
DataType,
GenerativeSearches,
Property,
ReferenceProperty,
Vectorizers,
_CollectionConfig,
)
from weaviate.exceptions import WeaviateClosedClientError, WeaviateStartUpError
import weaviate.classes as wvc

from weaviate.config import Timeout
from weaviate.exceptions import WeaviateClosedClientError, WeaviateStartUpError

WCS_HOST = "piblpmmdsiknacjnm1ltla.c1.europe-west3.gcp.weaviate.cloud"
WCS_URL = f"https://{WCS_HOST}"
Expand Down
2 changes: 1 addition & 1 deletion integration/test_client_debug.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import pytest

from integration.conftest import (
AsyncClientFactory,
AsyncCollectionFactory,
ClientFactory,
CollectionFactory,
)

from weaviate.classes.config import DataType, Property
from weaviate.classes.debug import DebugRESTObject

Expand Down
24 changes: 12 additions & 12 deletions integration/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,45 @@
import pytest

from integration.conftest import CollectionFactory, CollectionFactoryGet, _sanitize_collection_name
from integration.constants import WEAVIATE_LOGO_OLD_ENCODED, WEAVIATE_LOGO_NEW_ENCODED
from integration.constants import WEAVIATE_LOGO_NEW_ENCODED, WEAVIATE_LOGO_OLD_ENCODED
from weaviate.collections.classes.batch import ErrorObject
from weaviate.collections.classes.config import (
Configure,
ConsistencyLevel,
DataType,
Property,
ReferenceProperty,
Tokenization,
Vectorizers,
ConsistencyLevel,
)
from weaviate.collections.classes.data import (
DataObject,
)
from weaviate.collections.classes.grpc import (
QueryReference,
HybridFusion,
PROPERTIES,
PROPERTY,
REFERENCE,
GroupBy,
HybridFusion,
MetadataQuery,
Move,
NearMediaType,
QueryReference,
Sort,
_Sorting,
PROPERTIES,
PROPERTY,
REFERENCE,
NearMediaType,
)
from weaviate.collections.classes.internal import (
_CrossReference,
Object,
ReferenceToMulti,
_CrossReference,
)
from weaviate.collections.classes.types import PhoneNumber, _PhoneNumber, WeaviateProperties
from weaviate.collections.classes.types import PhoneNumber, WeaviateProperties, _PhoneNumber
from weaviate.exceptions import (
UnexpectedStatusCodeError,
WeaviateInvalidInputError,
WeaviateQueryError,
WeaviateInsertInvalidPropertyError,
WeaviateInsertManyAllFailedError,
WeaviateInvalidInputError,
WeaviateQueryError,
WeaviateUnsupportedFeatureError,
)
from weaviate.types import UUID, UUIDS
Expand Down
20 changes: 9 additions & 11 deletions integration/test_collection_aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,22 @@
AggregateDate,
AggregateInteger,
AggregateNumber,
AggregateText,
AggregateReturn,
Metrics,
AggregateText,
GroupByAggregate,
Metrics,
)
from weaviate.collections.classes.config import DataType, Property, ReferenceProperty, Configure
from weaviate.collections.classes.config import Configure, DataType, Property, ReferenceProperty
from weaviate.collections.classes.filters import Filter, _Filters
from weaviate.collections.classes.grpc import Move
from weaviate.collections.classes.tenants import Tenant
from weaviate.exceptions import (
WeaviateInvalidInputError,
WeaviateQueryError,
WeaviateUnsupportedFeatureError,
)
from weaviate.util import file_encoder_b64

from weaviate.collections.classes.grpc import Move

from weaviate.collections.classes.tenants import Tenant

UUID1 = uuid.UUID("8ad0d33c-8db1-4437-87f3-72161ca2a51a")
UUID2 = uuid.UUID("577887c1-4c6b-5594-aa62-f0c17883d9cf")

Expand Down Expand Up @@ -201,7 +199,7 @@ def test_over_all_with_filters_ref(collection_factory: CollectionFactory) -> Non
assert res.properties["text"].count == 1
assert res.properties["text"].top_occurrences[0].value == "two"

query = lambda: collection.aggregate.over_all(
query = lambda: collection.aggregate.over_all( # noqa: E731
filters=Filter.by_ref("ref").by_property("text").equal("one"),
return_metrics=[Metrics("text").text(count=True, top_occurrences_value=True)],
)
Expand Down Expand Up @@ -363,7 +361,7 @@ def test_hybrid_aggregation_group_by(
collection.data.insert({"text": text_1})
collection.data.insert({"text": text_2})

querier = lambda: collection.aggregate.hybrid(
querier = lambda: collection.aggregate.hybrid( # noqa: E731
"text",
alpha=0,
query_properties=["text"],
Expand Down Expand Up @@ -400,7 +398,7 @@ def test_hybrid_aggregation_group_by_with_named_vectors(
collection.data.insert({"text": text_1})
collection.data.insert({"text": text_2})

querier = lambda: collection.aggregate.hybrid(
querier = lambda: collection.aggregate.hybrid( # noqa: E731
"text",
alpha=0,
query_properties=["text"],
Expand Down Expand Up @@ -434,7 +432,7 @@ def test_hybrid_aggregation_group_by_with_named_vectors(
def test_near_vector_aggregation(
collection_factory: CollectionFactory, option: dict, expected_len: int
) -> None:
collection_maker = lambda: collection_factory(
collection_maker = lambda: collection_factory( # noqa: E731
properties=[Property(name="text", data_type=DataType.TEXT)],
vectorizer_config=Configure.Vectorizer.text2vec_contextionary(
vectorize_collection_name=False
Expand Down
5 changes: 2 additions & 3 deletions integration/test_collection_batch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import uuid
from dataclasses import dataclass
from typing import Generator, Optional, Union, Any, Protocol
from typing import Any, Generator, Optional, Protocol, Union

import pytest

Expand All @@ -13,9 +13,8 @@
ReferenceProperty,
)
from weaviate.collections.classes.grpc import QueryReference
from weaviate.collections.classes.internal import _CrossReference, ReferenceToMulti
from weaviate.collections.classes.internal import ReferenceToMulti, _CrossReference
from weaviate.collections.classes.tenants import Tenant

from weaviate.types import VECTORS

UUID = Union[str, uuid.UUID]
Expand Down
4 changes: 2 additions & 2 deletions integration/test_collection_batch_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
import pytest as pytest

from integration.conftest import CollectionFactory
from weaviate.classes.config import ConsistencyLevel
from weaviate.collections.classes.config import (
Configure,
Property,
DataType,
Property,
ReferenceProperty,
Tokenization,
)
Expand All @@ -19,7 +20,6 @@
)
from weaviate.collections.classes.internal import ReferenceToMulti
from weaviate.collections.classes.tenants import Tenant
from weaviate.classes.config import ConsistencyLevel
from weaviate.exceptions import (
WeaviateQueryException,
)
Expand Down
Loading