Skip to content

Commit

Permalink
Upgrade pylint and black, closes #797
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmezzetti committed Oct 11, 2024
1 parent bbddcd2 commit c3b3fc9
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion examples/baseball.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ def search(self):

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]
Expand Down
1 change: 0 additions & 1 deletion src/python/txtai/embeddings/index/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Index imports
"""


from .action import Action
from .autoid import AutoId
from .configuration import Configuration
Expand Down
12 changes: 5 additions & 7 deletions src/python/txtai/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,11 @@ def reference(deviceid):
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
Expand Down
1 change: 0 additions & 1 deletion src/python/txtai/models/pooling/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Pooling imports
"""


from .base import Pooling
from .cls import ClsPooling
from .factory import PoolingFactory
Expand Down
8 changes: 5 additions & 3 deletions src/python/txtai/scoring/pgtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ def initialize(self, recreate=False):
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
Expand Down

0 comments on commit c3b3fc9

Please sign in to comment.