Skip to content

armgit / txtai

Public Imported from GitHub
0

💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows

Upgrade pylint and black, closes #797

davidmezzettic3b3fc99153b
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index c7b9913f..24e61b88 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -47,7 +47,7 @@ jobs:
- name: Build
run: |
pip install -U wheel
- pip install .[all,dev]
+ pip install .[all,dev] fasttext==0.9.2
python -c "import nltk; nltk.download(['punkt', 'punkt_tab', 'averaged_perceptron_tagger_eng'])"
python --version
make data coverage
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 163e6c41..79f065d4 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,13 +1,14 @@
repos:
- repo: https://github.com/pycqa/pylint
- rev: v2.16.2
+ rev: v3.3.1
hooks:
- id: pylint
args:
- -d import-error
- -d duplicate-code
+ - -d too-many-positional-arguments
- repo: https://github.com/ambv/black
- rev: 23.1.0
+ rev: 24.10.0
hooks:
- id: black
language_version: python3
diff --git a/examples/baseball.py b/examples/baseball.py
index 58f81cb3..80cd7207 100644
--- a/examples/baseball.py
+++ b/examples/baseball.py
@@ -497,7 +497,7 @@ class Application:
st.markdown("Find players with similar statistics.")
- category = self.category("Batting", "searchcategory")
+ stats, category = None, self.category("Batting", "searchcategory")
with st.form("search"):
if category == "Batting":
stats, columns = self.batting, self.batting.columns[:-6]
diff --git a/src/python/txtai/embeddings/index/__init__.py b/src/python/txtai/embeddings/index/__init__.py
index 013d4191..5b3a1f18 100644
--- a/src/python/txtai/embeddings/index/__init__.py
+++ b/src/python/txtai/embeddings/index/__init__.py
@@ -2,7 +2,6 @@
Index imports
"""
-
from .action import Action
from .autoid import AutoId
from .configuration import Configuration
diff --git a/src/python/txtai/models/models.py b/src/python/txtai/models/models.py
index 3c42da36..ce0cc2a8 100644
--- a/src/python/txtai/models/models.py
+++ b/src/python/txtai/models/models.py
@@ -127,13 +127,11 @@ class Models:
return (
deviceid
if isinstance(deviceid, str)
- else "cpu"
- if deviceid < 0
- else f"cuda:{deviceid}"
- if torch.cuda.is_available()
- else "mps"
- if Models.hasmpsdevice()
- else Models.finddevice()
+ else (
+ "cpu"
+ if deviceid < 0
+ else f"cuda:{deviceid}" if torch.cuda.is_available() else "mps" if Models.hasmpsdevice() else Models.finddevice()
+ )
)
@staticmethod
diff --git a/src/python/txtai/models/pooling/__init__.py b/src/python/txtai/models/pooling/__init__.py
index 41aa71a5..f5a8defe 100644
--- a/src/python/txtai/models/pooling/__init__.py
+++ b/src/python/txtai/models/pooling/__init__.py
@@ -2,7 +2,6 @@
Pooling imports
"""
-
from .base import Pooling
from .cls import ClsPooling
from .factory import PoolingFactory
diff --git a/src/python/txtai/scoring/pgtext.py b/src/python/txtai/scoring/pgtext.py
index e3bea03b..4646f05d 100644
--- a/src/python/txtai/scoring/pgtext.py
+++ b/src/python/txtai/scoring/pgtext.py
@@ -127,9 +127,11 @@ class PGText(Scoring):
MetaData(),
Column("indexid", Integer, primary_key=True, autoincrement=False),
Column("text", Text),
- Column("vector", TSVECTOR, Computed(f"to_tsvector('{self.language}', text)", persisted=True))
- if self.engine.dialect.name == "postgresql"
- else Column("vector", Integer),
+ (
+ Column("vector", TSVECTOR, Computed(f"to_tsvector('{self.language}', text)", persisted=True))
+ if self.engine.dialect.name == "postgresql"
+ else Column("vector", Integer)
+ ),
)
# Create ANN index - inner product is equal to cosine similarity on normalized vectors