Skip to content

lint: run linter #189

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

Merged
merged 3 commits into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ lint_diff format_diff: PYTHON_FILES=$(shell git diff --relative=. --name-only --

lint lint_diff:
[ "$(PYTHON_FILES)" = "" ] || poetry run ruff format $(PYTHON_FILES) --diff
[ "$(PYTHON_FILES)" = "" ] || poetry run ruff check $(PYTHON_FILES) --diff
[ "$(PYTHON_FILES)" = "" ] || poetry run mypy $(PYTHON_FILES)

format format_diff:
[ "$(PYTHON_FILES)" = "" ] || poetry run ruff format $(PYTHON_FILES)
[ "$(PYTHON_FILES)" = "" ] || poetry run ruff --fix $(PYTHON_FILES)
[ "$(PYTHON_FILES)" = "" ] || poetry run ruff check --fix $(PYTHON_FILES)

spell_check:
poetry run codespell --toml pyproject.toml
Expand Down
2 changes: 1 addition & 1 deletion langchain_postgres/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from importlib import metadata

from langchain_postgres.chat_message_histories import PostgresChatMessageHistory
from langchain_postgres.v2.engine import Column, PGEngine, ColumnDict
from langchain_postgres.translator import PGVectorTranslator
from langchain_postgres.v2.engine import Column, ColumnDict, PGEngine
from langchain_postgres.v2.vectorstores import PGVectorStore
from langchain_postgres.vectorstores import PGVector

Expand Down
2 changes: 1 addition & 1 deletion langchain_postgres/utils/pgvector_migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async def __aextract_pgvector_collection(
if not rows:
break
yield [row._mapping for row in rows]
except ValueError as e:
except ValueError:
raise ValueError(f"Collection, {collection_name} does not exist.")
except SQLAlchemyError as e:
raise ProgrammingError(
Expand Down
3 changes: 1 addition & 2 deletions langchain_postgres/v2/async_vectorstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import copy
import json
import re
import uuid
from typing import Any, Callable, Iterable, Optional, Sequence

Expand Down Expand Up @@ -834,7 +833,7 @@ async def is_valid_index(
) -> bool:
"""Check if index exists in the table."""
index_name = index_name or self.table_name + DEFAULT_INDEX_NAME_SUFFIX
query = f"""
query = """
SELECT tablename, indexname
FROM pg_indexes
WHERE tablename = :table_name AND schemaname = :schema_name AND indexname = :index_name;
Expand Down
4 changes: 2 additions & 2 deletions langchain_postgres/v2/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import asyncio
from dataclasses import dataclass
from threading import Thread
from typing import TYPE_CHECKING, Any, Awaitable, Optional, TypeVar, TypedDict, Union
from typing import TYPE_CHECKING, Any, Awaitable, Optional, TypedDict, TypeVar, Union

from sqlalchemy import text
from sqlalchemy.engine import URL
from sqlalchemy.ext.asyncio import AsyncEngine, create_async_engine

if TYPE_CHECKING:
import asyncpg # type: ignore
pass # type: ignore

T = TypeVar("T")

Expand Down
2 changes: 1 addition & 1 deletion langchain_postgres/vectorstores.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import enum
import logging
import uuid
import warnings
from typing import (
Any,
AsyncGenerator,
Expand All @@ -19,7 +20,6 @@
Type,
Union,
)
import warnings
from typing import (
cast as typing_cast,
)
Expand Down
5 changes: 2 additions & 3 deletions tests/unit_tests/v2/test_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import uuid
from typing import AsyncIterator, Sequence

import asyncpg # type: ignore
import pytest
import pytest_asyncio
from langchain_core.embeddings import DeterministicFakeEmbedding
Expand All @@ -11,7 +10,7 @@
from sqlalchemy.ext.asyncio import create_async_engine
from sqlalchemy.pool import NullPool

from langchain_postgres import Column, PGEngine, ColumnDict
from langchain_postgres import Column, PGEngine
from tests.utils import VECTORSTORE_CONNECTION_STRING as CONNECTION_STRING

DEFAULT_TABLE = "default" + str(uuid.uuid4()).replace("-", "_")
Expand Down Expand Up @@ -214,7 +213,7 @@ async def test_from_connection_string_url_error(
) -> None:
with pytest.raises(ValueError):
PGEngine.from_connection_string(
f"postgresql+pg8000://user:password@host:port/db_name",
"postgresql+pg8000://user:password@host:port/db_name",
)

async def test_column(self, engine: PGEngine) -> None:
Expand Down
1 change: 1 addition & 0 deletions tests/unit_tests/v2/test_indexes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import warnings

import pytest

from langchain_postgres.v2.indexes import (
Expand Down
3 changes: 1 addition & 2 deletions tests/unit_tests/v2/test_pg_vectorstore_from_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
import pytest_asyncio
from langchain_core.documents import Document
from langchain_core.embeddings import DeterministicFakeEmbedding
from sqlalchemy import VARCHAR, text
from sqlalchemy import text
from sqlalchemy.engine.row import RowMapping
from sqlalchemy.ext.asyncio import create_async_engine

from langchain_postgres import Column, PGEngine, PGVectorStore
from tests.utils import VECTORSTORE_CONNECTION_STRING as CONNECTION_STRING
Expand Down