Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop black #623

Merged
merged 6 commits into from
May 7, 2024
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
21 changes: 9 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@ repos:
- id: end-of-file-fixer
- id: check-added-large-files

- repo: https://github.com/psf/black
rev: 23.12.1
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.3
hooks:
- id: black
name: "Black: The uncompromising Python code formatter"
args: ["--line-length", "99"]

- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
name: "Sort Imports"
args: ["--profile", "black", "--py", "310"]
Comment on lines -25 to -28
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is isort missing in the new definition?

https://docs.astral.sh/ruff/formatter/#sorting-imports

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed as well

# ToDo: re-introduce ruff linter later
# - id: ruff
# types_or: [ python, pyi ]
# args: [ --fix ]
- id: ruff-format
types_or: [ python, pyi ]
args: [ --line-length=99 ]
302 changes: 157 additions & 145 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ coverage = "^6.3.3"
pytest-asyncio = "^0.21.0"
pytest-timeout = "^2.1.0"
autoflake = "^2.2.1"
isort = "5.13.2"
black = "23.12.1"
ruff = "0.4.3"


[tool.poetry.group.docs.dependencies]
sphinx = "^4.5.0"
Expand Down
1 change: 0 additions & 1 deletion qdrant_client/async_client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
# ****** WARNING: THIS FILE IS AUTOGENERATED ******

from typing import Any, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple, Union

from qdrant_client.conversions import common_types as types
from qdrant_client.http import models

Expand Down
5 changes: 2 additions & 3 deletions qdrant_client/async_qdrant_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@
Tuple,
Union,
)

from qdrant_client import grpc as grpc
from qdrant_client.async_client_base import AsyncQdrantBase
from qdrant_client.async_qdrant_fastembed import AsyncQdrantFastembedMixin
from qdrant_client.async_qdrant_remote import AsyncQdrantRemote
from qdrant_client.conversions import common_types as types
from qdrant_client.http import AsyncApiClient, AsyncApis
from qdrant_client.local.async_qdrant_local import AsyncQdrantLocal
from qdrant_client.async_qdrant_fastembed import AsyncQdrantFastembedMixin
from qdrant_client.async_qdrant_remote import AsyncQdrantRemote


class AsyncQdrantClient(AsyncQdrantFastembedMixin):
Expand Down
3 changes: 2 additions & 1 deletion qdrant_client/async_qdrant_fastembed.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import warnings
from itertools import tee
from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple, Union

from qdrant_client.async_client_base import AsyncQdrantBase
from qdrant_client.conversions import common_types as types
from qdrant_client.fastembed_common import QueryResponse
Expand Down Expand Up @@ -54,6 +53,8 @@ def __init__(self, **kwargs: Any):
try:
from fastembed import SparseTextEmbedding, TextEmbedding

assert len(SparseTextEmbedding.list_supported_models()) > 0
assert len(TextEmbedding.list_supported_models()) > 0
self.__class__._FASTEMBED_INSTALLED = True
except ImportError:
self.__class__._FASTEMBED_INSTALLED = False
Expand Down
4 changes: 1 addition & 3 deletions qdrant_client/async_qdrant_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,14 @@
Union,
get_args,
)

import httpx
import numpy as np
from grpc import Compression
from urllib3.util import Url, parse_url

from qdrant_client import grpc as grpc
from qdrant_client._pydantic_compat import construct
from qdrant_client.async_client_base import AsyncQdrantBase
from qdrant_client.auth import BearerAuth
from qdrant_client.async_client_base import AsyncQdrantBase
from qdrant_client.connection import get_async_channel as get_channel
from qdrant_client.conversions import common_types as types
from qdrant_client.conversions.common_types import get_args_subscribed
Expand Down
21 changes: 4 additions & 17 deletions qdrant_client/local/async_qdrant_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,10 @@
import os
import shutil
from io import TextIOWrapper
from typing import (
Any,
Dict,
Generator,
Iterable,
List,
Mapping,
Optional,
Sequence,
Tuple,
Union,
)
from typing import Any, Dict, Generator, Iterable, List, Mapping, Optional, Sequence, Tuple, Union
from uuid import uuid4

import numpy as np
import portalocker

from qdrant_client._pydantic_compat import to_dict
from qdrant_client.async_client_base import AsyncQdrantBase
from qdrant_client.conversions import common_types as types
Expand Down Expand Up @@ -540,9 +527,9 @@ async def update_collection_aliases(
for operation in change_aliases_operations:
if isinstance(operation, rest_models.CreateAliasOperation):
self._get_collection(operation.create_alias.collection_name)
self.aliases[
operation.create_alias.alias_name
] = operation.create_alias.collection_name
self.aliases[operation.create_alias.alias_name] = (
operation.create_alias.collection_name
)
elif isinstance(operation, rest_models.DeleteAliasOperation):
self.aliases.pop(operation.delete_alias.alias_name, None)
elif isinstance(operation, rest_models.RenameAliasOperation):
Expand Down
5 changes: 4 additions & 1 deletion qdrant_client/qdrant_fastembed.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ def __init__(self, **kwargs: Any):
self._embedding_model_name: Optional[str] = None
self._sparse_embedding_model_name: Optional[str] = None
try:
from fastembed import SparseTextEmbedding, TextEmbedding # noqa: F401
from fastembed import SparseTextEmbedding, TextEmbedding

assert len(SparseTextEmbedding.list_supported_models()) > 0
assert len(TextEmbedding.list_supported_models()) > 0

self.__class__._FASTEMBED_INSTALLED = True
except ImportError:
Expand Down
3 changes: 1 addition & 2 deletions tools/generate_async_client.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ mv async_qdrant_local.py $ABSOLUTE_PROJECT_ROOT/qdrant_client/async_qdrant_local
cd $ABSOLUTE_PROJECT_ROOT/qdrant_client

ls -1 async*.py | autoflake --recursive --imports qdrant_client --remove-unused-variables --in-place async*.py
ls -1 async*.py | xargs -I {} isort --profile black --py 310 {}
ls -1 async*.py | xargs -I {} black -l 99 --target-version py310 {}
ls -1 async*.py | xargs -I {} ruff format --line-length 99 {}

mv async_qdrant_local.py local/async_qdrant_local.py
Loading