mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-17 23:41:46 +00:00
huggingface[patch]: ruff fixes and rules (#31912)
* bump ruff deps * add more thorough ruff rules * fix said rules
This commit is contained in:
@@ -4,4 +4,3 @@ import pytest # type: ignore[import-not-found, import-not-found]
|
||||
@pytest.mark.compile
|
||||
def test_placeholder() -> None:
|
||||
"""Used for compiling integration tests without running any real tests."""
|
||||
pass
|
||||
|
@@ -1,4 +1,4 @@
|
||||
"""Standard LangChain interface tests"""
|
||||
"""Standard LangChain interface tests."""
|
||||
|
||||
import pytest
|
||||
from langchain_core.language_models import BaseChatModel
|
||||
|
@@ -31,8 +31,7 @@ def mock_llm() -> Mock:
|
||||
"langchain_huggingface.chat_models.huggingface.ChatHuggingFace._resolve_model_id"
|
||||
)
|
||||
def chat_hugging_face(mock_resolve_id: Any, mock_llm: Any) -> ChatHuggingFace:
|
||||
chat_hf = ChatHuggingFace(llm=mock_llm, tokenizer=MagicMock())
|
||||
return chat_hf
|
||||
return ChatHuggingFace(llm=mock_llm, tokenizer=MagicMock())
|
||||
|
||||
|
||||
def test_create_chat_result(chat_hugging_face: Any) -> None:
|
||||
|
@@ -6,8 +6,7 @@ DEFAULT_MODEL_ID = "gpt2"
|
||||
|
||||
|
||||
def test_initialization_default() -> None:
|
||||
"""Test default initialization"""
|
||||
|
||||
"""Test default initialization."""
|
||||
llm = HuggingFacePipeline()
|
||||
|
||||
assert llm.model_id == DEFAULT_MODEL_ID
|
||||
@@ -15,8 +14,7 @@ def test_initialization_default() -> None:
|
||||
|
||||
@patch("transformers.pipeline")
|
||||
def test_initialization_with_pipeline(mock_pipeline: MagicMock) -> None:
|
||||
"""Test initialization with a pipeline object"""
|
||||
|
||||
"""Test initialization with a pipeline object."""
|
||||
mock_pipe = MagicMock()
|
||||
mock_pipe.model.name_or_path = "mock-model-id"
|
||||
mock_pipeline.return_value = mock_pipe
|
||||
@@ -32,8 +30,7 @@ def test_initialization_with_pipeline(mock_pipeline: MagicMock) -> None:
|
||||
def test_initialization_with_from_model_id(
|
||||
mock_pipeline: MagicMock, mock_model: MagicMock, mock_tokenizer: MagicMock
|
||||
) -> None:
|
||||
"""Test initialization with the from_model_id method"""
|
||||
|
||||
"""Test initialization with the from_model_id method."""
|
||||
mock_tokenizer.return_value = MagicMock(pad_token_id=0)
|
||||
mock_model.return_value = MagicMock()
|
||||
|
||||
|
Reference in New Issue
Block a user