Skip to content

Commit 404d840

Browse files
authored
langchain-nomic[patch]: Add ruff bandit rules to linter (#31805)
- Add ruff bandit rules - Some formatting
1 parent 0279af6 commit 404d840

File tree

3 files changed

+864
-857
lines changed

3 files changed

+864
-857
lines changed

libs/partners/nomic/langchain_nomic/embeddings.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class NomicEmbeddings(Embeddings):
1010
"""NomicEmbeddings embedding model.
1111
1212
Example:
13+
1314
.. code-block:: python
1415
1516
from langchain_nomic import NomicEmbeddings
@@ -66,16 +67,16 @@ def __init__(
6667
6768
Args:
6869
model: model name
69-
nomic_api_key: optionally, set the Nomic API key. Uses the NOMIC_API_KEY
70+
nomic_api_key: optionally, set the Nomic API key. Uses the ``NOMIC_API_KEY``
7071
environment variable by default.
7172
dimensionality: The embedding dimension, for use with Matryoshka-capable
7273
models. Defaults to full-size.
73-
inference_mode: How to generate embeddings. One of `remote`, `local`
74-
(Embed4All), or `dynamic` (automatic). Defaults to `remote`.
74+
inference_mode: How to generate embeddings. One of ``'remote'``, ``'local'``
75+
(Embed4All), or ``'dynamic'`` (automatic). Defaults to ``'remote'``.
7576
device: The device to use for local embeddings. Choices include
76-
`cpu`, `gpu`, `nvidia`, `amd`, or a specific device name. See
77-
the docstring for `GPT4All.__init__` for more info. Typically
78-
defaults to CPU. Do not use on macOS.
77+
``'cpu'``, ``'gpu'``, ``'nvidia'``, ``'amd'``, or a specific device
78+
name. See the docstring for ``GPT4All.__init__`` for more info.
79+
Typically defaults to ``'cpu'``. Do not use on macOS.
7980
"""
8081
_api_key = nomic_api_key or os.environ.get("NOMIC_API_KEY")
8182
if _api_key:
@@ -91,8 +92,8 @@ def embed(self, texts: list[str], *, task_type: str) -> list[list[float]]:
9192
9293
Args:
9394
texts: list of texts to embed
94-
task_type: the task type to use when embedding. One of `search_query`,
95-
`search_document`, `classification`, `clustering`
95+
task_type: the task type to use when embedding. One of ``'search_query'``,
96+
``'search_document'``, ``'classification'``, ``'clustering'``
9697
"""
9798

9899
output = embed.text(

libs/partners/nomic/pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ select = [
5050
"I", # isort
5151
"T201", # print
5252
"UP", # pyupgrade
53+
"S", # security
5354
]
5455
ignore = [ "UP007", ]
5556

@@ -77,3 +78,9 @@ markers = [
7778
"compile: mark placeholder test used to compile integration tests without running them",
7879
]
7980
asyncio_mode = "auto"
81+
82+
[tool.ruff.lint.extend-per-file-ignores]
83+
"tests/**/*.py" = [
84+
"S101", # Tests need assertions
85+
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
86+
]

0 commit comments

Comments
 (0)