From 2e1838a62a3d4c0e3877eb4aa735736f5459af5d Mon Sep 17 00:00:00 2001 From: Chang She <759245+changhiskhan@users.noreply.github.com> Date: Mon, 4 Mar 2024 17:16:24 -0800 Subject: [PATCH] ruff --- python/pyproject.toml | 2 +- python/python/lancedb/pydantic.py | 5 +++-- python/python/tests/test_cli.py | 1 - python/python/tests/test_context.py | 1 - python/python/tests/test_db.py | 2 -- python/python/tests/test_e2e_remote_db.py | 1 - python/python/tests/test_embeddings.py | 3 +-- python/python/tests/test_embeddings_slow.py | 6 ++---- python/python/tests/test_fts.py | 3 +-- python/python/tests/test_io.py | 3 +-- python/python/tests/test_query.py | 1 - python/python/tests/test_remote_client.py | 1 - python/python/tests/test_remote_db.py | 3 +-- python/python/tests/test_rerankers.py | 3 +-- python/python/tests/test_telemetry.py | 3 +-- python/python/tests/test_util.py | 1 - 16 files changed, 12 insertions(+), 27 deletions(-) diff --git a/python/pyproject.toml b/python/pyproject.toml index dec1edc1..81772ecf 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -57,7 +57,7 @@ tests = [ "duckdb", "pytz", "polars>=0.19", - "PIL" + "pillow", ] dev = ["ruff", "pre-commit"] docs = [ diff --git a/python/python/lancedb/pydantic.py b/python/python/lancedb/pydantic.py index bf14b80f..696ea7ef 100644 --- a/python/python/lancedb/pydantic.py +++ b/python/python/lancedb/pydantic.py @@ -36,7 +36,6 @@ from typing import ( import numpy as np import pyarrow as pa import pydantic -from .util import attempt_import_or_raise import semver from lance.arrow import ( EncodedImageType, @@ -44,6 +43,8 @@ from lance.arrow import ( from pydantic.fields import FieldInfo from pydantic_core import core_schema +from .util import attempt_import_or_raise + PYDANTIC_VERSION = semver.Version.parse(pydantic.__version__) if TYPE_CHECKING: @@ -204,7 +205,7 @@ class ImageMixin(ABC): def EncodedImage(): - attempt_import_or_raise("PIL", "PIL or pip install lancedb[embeddings]") + attempt_import_or_raise("PIL", "pillow or pip install lancedb[embeddings]") import PIL.Image class EncodedImage(bytes, ImageMixin): diff --git a/python/python/tests/test_cli.py b/python/python/tests/test_cli.py index f43e0fb3..afc88888 100644 --- a/python/python/tests/test_cli.py +++ b/python/python/tests/test_cli.py @@ -1,5 +1,4 @@ from click.testing import CliRunner - from lancedb.cli.cli import cli from lancedb.utils import CONFIG diff --git a/python/python/tests/test_context.py b/python/python/tests/test_context.py index 75adb348..bcd1d63c 100644 --- a/python/python/tests/test_context.py +++ b/python/python/tests/test_context.py @@ -13,7 +13,6 @@ import pandas as pd import pytest - from lancedb.context import contextualize diff --git a/python/python/tests/test_db.py b/python/python/tests/test_db.py index 6ae1be49..c84c0800 100644 --- a/python/python/tests/test_db.py +++ b/python/python/tests/test_db.py @@ -19,8 +19,6 @@ import numpy as np import pandas as pd import pyarrow as pa import pytest - -import lancedb from lancedb.pydantic import LanceModel, Vector diff --git a/python/python/tests/test_e2e_remote_db.py b/python/python/tests/test_e2e_remote_db.py index e9e69c48..f058092e 100644 --- a/python/python/tests/test_e2e_remote_db.py +++ b/python/python/tests/test_e2e_remote_db.py @@ -13,7 +13,6 @@ import numpy as np import pytest - from lancedb import LanceDBConnection # TODO: setup integ test mark and script diff --git a/python/python/tests/test_embeddings.py b/python/python/tests/test_embeddings.py index 32142a57..af442a16 100644 --- a/python/python/tests/test_embeddings.py +++ b/python/python/tests/test_embeddings.py @@ -13,11 +13,10 @@ import sys import lance +import lancedb import numpy as np import pyarrow as pa import pytest - -import lancedb from lancedb.conftest import MockTextEmbeddingFunction from lancedb.embeddings import ( EmbeddingFunctionConfig, diff --git a/python/python/tests/test_embeddings_slow.py b/python/python/tests/test_embeddings_slow.py index 11b024f0..9dc85bfc 100644 --- a/python/python/tests/test_embeddings_slow.py +++ b/python/python/tests/test_embeddings_slow.py @@ -14,12 +14,11 @@ import importlib import io import os +import lancedb import numpy as np import pandas as pd import pytest import requests - -import lancedb from lancedb.embeddings import get_registry from lancedb.pydantic import LanceModel, Vector @@ -185,10 +184,9 @@ def test_imagebind(tmp_path): import shutil import tempfile + import lancedb.embeddings.imagebind import pandas as pd import requests - - import lancedb.embeddings.imagebind from lancedb.embeddings import get_registry from lancedb.pydantic import LanceModel, Vector diff --git a/python/python/tests/test_fts.py b/python/python/tests/test_fts.py index e2f1d070..fbf74662 100644 --- a/python/python/tests/test_fts.py +++ b/python/python/tests/test_fts.py @@ -14,12 +14,11 @@ import os import random from unittest import mock +import lancedb as ldb import numpy as np import pandas as pd import pytest -import lancedb as ldb - pytest.importorskip("lancedb.fts") tantivy = pytest.importorskip("tantivy") diff --git a/python/python/tests/test_io.py b/python/python/tests/test_io.py index 0629e809..10b749b2 100644 --- a/python/python/tests/test_io.py +++ b/python/python/tests/test_io.py @@ -13,9 +13,8 @@ import os -import pytest - import lancedb +import pytest # You need to setup AWS credentials an a base path to run this test. Example # AWS_PROFILE=default TEST_S3_BASE_URL=s3://my_bucket/dataset pytest tests/test_io.py diff --git a/python/python/tests/test_query.py b/python/python/tests/test_query.py index 9e257bbe..d1a08666 100644 --- a/python/python/tests/test_query.py +++ b/python/python/tests/test_query.py @@ -18,7 +18,6 @@ import numpy as np import pandas.testing as tm import pyarrow as pa import pytest - from lancedb.db import LanceDBConnection from lancedb.pydantic import LanceModel, Vector from lancedb.query import LanceVectorQueryBuilder, Query diff --git a/python/python/tests/test_remote_client.py b/python/python/tests/test_remote_client.py index 73ebf153..e9a2b19f 100644 --- a/python/python/tests/test_remote_client.py +++ b/python/python/tests/test_remote_client.py @@ -17,7 +17,6 @@ import pandas as pd import pyarrow as pa import pytest from aiohttp import web - from lancedb.remote.client import RestfulLanceDBClient, VectorQuery diff --git a/python/python/tests/test_remote_db.py b/python/python/tests/test_remote_db.py index f4aff298..a775d5c7 100644 --- a/python/python/tests/test_remote_db.py +++ b/python/python/tests/test_remote_db.py @@ -11,9 +11,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pyarrow as pa - import lancedb +import pyarrow as pa from lancedb.remote.client import VectorQuery, VectorQueryResult diff --git a/python/python/tests/test_rerankers.py b/python/python/tests/test_rerankers.py index 905aa1e0..a912c64b 100644 --- a/python/python/tests/test_rerankers.py +++ b/python/python/tests/test_rerankers.py @@ -1,9 +1,8 @@ import os +import lancedb import numpy as np import pytest - -import lancedb from lancedb.conftest import MockTextEmbeddingFunction # noqa from lancedb.embeddings import EmbeddingFunctionRegistry from lancedb.pydantic import LanceModel, Vector diff --git a/python/python/tests/test_telemetry.py b/python/python/tests/test_telemetry.py index b8923408..d2865e7e 100644 --- a/python/python/tests/test_telemetry.py +++ b/python/python/tests/test_telemetry.py @@ -1,8 +1,7 @@ import json -import pytest - import lancedb +import pytest from lancedb.utils.events import _Events diff --git a/python/python/tests/test_util.py b/python/python/tests/test_util.py index 1bf3e693..fa7e75f0 100644 --- a/python/python/tests/test_util.py +++ b/python/python/tests/test_util.py @@ -15,7 +15,6 @@ import os import pathlib import pytest - from lancedb.util import get_uri_scheme, join_uri