Skip to content

Commit e7f1cee

Browse files
authored
nomic[patch]: ruff fixes and rules (#31922)
* bump ruff deps * add more thorough ruff rules * fix said rules * fix makefile targets
1 parent 71b3619 commit e7f1cee

File tree

5 files changed

+90
-38
lines changed

5 files changed

+90
-38
lines changed

libs/partners/nomic/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ lint_tests: PYTHON_FILES=tests
3535
lint_tests: MYPY_CACHE=.mypy_cache_test
3636

3737
lint lint_diff lint_package lint_tests:
38-
[ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff $(PYTHON_FILES)
38+
[ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check $(PYTHON_FILES)
3939
[ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES) --diff
4040
[ "$(PYTHON_FILES)" = "" ] || mkdir -p $(MYPY_CACHE) && uv run --all-groups mypy $(PYTHON_FILES) --cache-dir $(MYPY_CACHE)
4141

4242
format format_diff:
4343
[ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES)
44-
[ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff --fix $(PYTHON_FILES)
44+
[ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --fix $(PYTHON_FILES)
4545

4646
spell_check:
4747
uv run --all-groups codespell --toml pyproject.toml

libs/partners/nomic/langchain_nomic/embeddings.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import os
24
from typing import Literal, Optional, overload
35

@@ -16,6 +18,7 @@ class NomicEmbeddings(Embeddings):
1618
from langchain_nomic import NomicEmbeddings
1719
1820
model = NomicEmbeddings()
21+
1922
"""
2023

2124
@overload
@@ -26,8 +29,7 @@ def __init__(
2629
nomic_api_key: Optional[str] = ...,
2730
dimensionality: Optional[int] = ...,
2831
inference_mode: Literal["remote"] = ...,
29-
):
30-
...
32+
): ...
3133

3234
@overload
3335
def __init__(
@@ -38,8 +40,7 @@ def __init__(
3840
dimensionality: Optional[int] = ...,
3941
inference_mode: Literal["local", "dynamic"],
4042
device: Optional[str] = ...,
41-
):
42-
...
43+
): ...
4344

4445
@overload
4546
def __init__(
@@ -50,8 +51,7 @@ def __init__(
5051
dimensionality: Optional[int] = ...,
5152
inference_mode: str,
5253
device: Optional[str] = ...,
53-
):
54-
...
54+
): ...
5555

5656
def __init__(
5757
self,
@@ -77,6 +77,8 @@ def __init__(
7777
``'cpu'``, ``'gpu'``, ``'nvidia'``, ``'amd'``, or a specific device
7878
name. See the docstring for ``GPT4All.__init__`` for more info.
7979
Typically defaults to ``'cpu'``. Do not use on macOS.
80+
vision_model: The vision model to use for image embeddings.
81+
8082
"""
8183
_api_key = nomic_api_key or os.environ.get("NOMIC_API_KEY")
8284
if _api_key:
@@ -94,8 +96,8 @@ def embed(self, texts: list[str], *, task_type: str) -> list[list[float]]:
9496
texts: list of texts to embed
9597
task_type: the task type to use when embedding. One of ``'search_query'``,
9698
``'search_document'``, ``'classification'``, ``'clustering'``
97-
"""
9899
100+
"""
99101
output = embed.text(
100102
texts=texts,
101103
model=self.model,
@@ -111,6 +113,7 @@ def embed_documents(self, texts: list[str]) -> list[list[float]]:
111113
112114
Args:
113115
texts: list of texts to embed as documents
116+
114117
"""
115118
return self.embed(
116119
texts=texts,
@@ -122,6 +125,7 @@ def embed_query(self, text: str) -> list[float]:
122125
123126
Args:
124127
text: query text
128+
125129
"""
126130
return self.embed(
127131
texts=[text],

libs/partners/nomic/pyproject.toml

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,62 @@ target-version = "py39"
4545

4646
[tool.ruff.lint]
4747
select = [
48-
"E", # pycodestyle
49-
"F", # pyflakes
50-
"I", # isort
51-
"T201", # print
52-
"UP", # pyupgrade
53-
"S", # flake8-bandit
48+
"A", # flake8-builtins
49+
"B", # flake8-bugbear
50+
"ASYNC", # flake8-async
51+
"C4", # flake8-comprehensions
52+
"COM", # flake8-commas
53+
"D", # pydocstyle
54+
"DOC", # pydoclint
55+
"E", # pycodestyle error
56+
"EM", # flake8-errmsg
57+
"F", # pyflakes
58+
"FA", # flake8-future-annotations
59+
"FBT", # flake8-boolean-trap
60+
"FLY", # flake8-flynt
61+
"I", # isort
62+
"ICN", # flake8-import-conventions
63+
"INT", # flake8-gettext
64+
"ISC", # isort-comprehensions
65+
"PGH", # pygrep-hooks
66+
"PIE", # flake8-pie
67+
"PERF", # flake8-perf
68+
"PYI", # flake8-pyi
69+
"Q", # flake8-quotes
70+
"RET", # flake8-return
71+
"RSE", # flake8-rst-docstrings
72+
"RUF", # ruff
73+
"S", # flake8-bandit
74+
"SLF", # flake8-self
75+
"SLOT", # flake8-slots
76+
"SIM", # flake8-simplify
77+
"T10", # flake8-debugger
78+
"T20", # flake8-print
79+
"TID", # flake8-tidy-imports
80+
"UP", # pyupgrade
81+
"W", # pycodestyle warning
82+
"YTT", # flake8-2020
5483
]
55-
ignore = [ "UP007", ]
84+
ignore = [
85+
"D100", # pydocstyle: Missing docstring in public module
86+
"D101", # pydocstyle: Missing docstring in public class
87+
"D102", # pydocstyle: Missing docstring in public method
88+
"D103", # pydocstyle: Missing docstring in public function
89+
"D104", # pydocstyle: Missing docstring in public package
90+
"D105", # pydocstyle: Missing docstring in magic method
91+
"D107", # pydocstyle: Missing docstring in __init__
92+
"D203", # Messes with the formatter
93+
"D407", # pydocstyle: Missing-dashed-underline-after-section
94+
"COM812", # Messes with the formatter
95+
"ISC001", # Messes with the formatter
96+
"PERF203", # Rarely useful
97+
"S112", # Rarely useful
98+
"RUF012", # Doesn't play well with Pydantic
99+
"SLF001", # Private member access
100+
"UP007", # pyupgrade: non-pep604-annotation-union
101+
"UP045", # pyupgrade: non-pep604-annotation-optional
102+
]
103+
unfixable = ["B028"] # People should intentionally tune the stacklevel
56104

57105
[tool.mypy]
58106
disallow_untyped_defs = "True"

libs/partners/nomic/tests/integration_tests/test_compile.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@
44
@pytest.mark.compile
55
def test_placeholder() -> None:
66
"""Used for compiling integration tests without running any real tests."""
7-
pass

libs/partners/nomic/uv.lock

Lines changed: 22 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)