Skip to content

Commit 7a430ac

Browse files
committed
fix: F rule, A rule, update ruff
1 parent 5a8578d commit 7a430ac

5 files changed

Lines changed: 7 additions & 12 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ repos:
2222
hooks:
2323
- id: pydoclint
2424
- repo: https://github.com/astral-sh/ruff-pre-commit
25-
rev: v0.4.10
25+
rev: v0.13.0
2626
hooks:
2727
- id: ruff
2828
args: [ --fix ]

model2vec/model.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from logging import getLogger
66
from pathlib import Path
77
from tempfile import TemporaryDirectory
8-
from typing import Any, Iterator, Sequence, Union, cast, overload
8+
from typing import Any, Iterator, Sequence, Union, overload
99

1010
import numpy as np
1111
from joblib import delayed
@@ -493,8 +493,6 @@ def quantize_model(
493493
:return: A new StaticModel with the quantized embeddings.
494494
:raises: ValueError if the model is already quantized.
495495
"""
496-
from model2vec.quantization import quantize_and_reduce_dim
497-
498496
token_mapping: np.ndarray | None
499497
weights: np.ndarray | None
500498
if vocabulary_quantization is not None:

model2vec/utils.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import annotations
33

4-
import json
54
import logging
65
import re
76
from importlib import import_module
87
from importlib.metadata import metadata
9-
from pathlib import Path
10-
from typing import Any, Iterator, Protocol, cast
8+
from typing import Any, Iterator, Protocol
119

1210
import numpy as np
13-
import safetensors
1411
from joblib import Parallel
15-
from tokenizers import Tokenizer
1612
from tqdm import tqdm
1713

1814
logger = logging.getLogger(__name__)

model2vec/vocabulary_quantization.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
from sklearn.cluster import KMeans
1111
except ImportError:
1212
raise ImportError(
13-
"scikit-learn is required for quantizing the vocabulary. "
14-
"Please install model2vec with the quantization extra."
13+
"scikit-learn is required for quantizing the vocabulary. Please install model2vec with the quantization extra."
1514
)
1615

1716

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ select = [
8686
"C90",
8787
# Pydocstyle: Enforce docstrings
8888
"D",
89+
# Remove unused imports
90+
"F",
8991
# Isort: Enforce import order
9092
"I",
9193
# Numpy: Enforce numpy style
@@ -96,7 +98,7 @@ select = [
9698

9799
ignore = [
98100
# Allow self and cls to be untyped, and allow Any type
99-
"ANN101", "ANN102", "ANN401",
101+
"ANN001", "ANN002", "ANN401",
100102
# Pydocstyle ignores
101103
"D100", "D101", "D104", "D203", "D212", "D401",
102104
# Allow use of f-strings in logging

0 commit comments

Comments
 (0)