ruff: add bugbear across packages (#31917)

WIP, other packages will get in next PRs
This commit is contained in:
Mason Daugherty
2025-07-08 12:22:55 -04:00
committed by GitHub
parent 5b3e29f809
commit ae210c1590
33 changed files with 59 additions and 42 deletions

View File

@@ -98,12 +98,12 @@ class HuggingFaceEndpointEmbeddings(BaseModel, Embeddings):
self.client = client
self.async_client = async_client
except ImportError:
except ImportError as e:
msg = (
"Could not import huggingface_hub python package. "
"Please install it with `pip install huggingface_hub`."
)
raise ImportError(msg)
raise ImportError(msg) from e
return self
def embed_documents(self, texts: list[str]) -> list[list[float]]:

View File

@@ -115,12 +115,12 @@ class HuggingFacePipeline(BaseLLM):
)
from transformers import pipeline as hf_pipeline # type: ignore[import]
except ImportError:
except ImportError as e:
msg = (
"Could not import transformers python package. "
"Please install it with `pip install transformers`."
)
raise ValueError(msg)
raise ValueError(msg) from e
_model_kwargs = model_kwargs.copy() if model_kwargs else {}
if device_map is not None:

View File

@@ -60,6 +60,7 @@ target-version = "py39"
[tool.ruff.lint]
select = [
"A", # flake8-builtins
"B", # flake8-bugbear
"ASYNC", # flake8-async
"C4", # flake8-comprehensions
"COM", # flake8-commas
@@ -110,7 +111,6 @@ ignore = [
"RUF012", # Doesn't play well with Pydantic
"SLF001", # Private member access
"UP007", # pyupgrade: non-pep604-annotation-union
]
[tool.coverage.run]