diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 14b0e6b..c1e03aa 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,7 +17,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: "3.12" + python-version: "3.13" cache: 'pip' - name: Install dependencies @@ -36,7 +36,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: "3.12" + python-version: "3.13" cache: 'pip' - name: Install dependencies @@ -55,7 +55,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: "3.12" + python-version: "3.13" cache: 'pip' - name: Install dependencies @@ -74,7 +74,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: "3.12" + python-version: "3.13" cache: 'pip' - name: Install dependencies @@ -94,7 +94,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: "3.12" + python-version: "3.13" cache: 'pip' - name: Install dependencies @@ -125,7 +125,7 @@ jobs: matrix: db: [ sqlite, mariadb ] django-version: [ "~=5.0" ] - python-version: [ "3.12" ] + python-version: ["3.12", "3.13" ] services: mariadb: @@ -187,7 +187,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: "3.12" + python-version: "3.13" - name: Install dependencies run: | @@ -227,7 +227,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-python@v5 with: - python-version: "3.12" + python-version: "3.13" - name: Install dependencies run: | pip install git+https://${{ secrets.ORGANIZATIONAL_REPO_TOKEN }}@github.com/pivotal-energy-solutions/tensor-infrastructure@master#egg=infrastructure diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c91bfa9..e5c91c8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,5 @@ default_language_version: - python: python3.10 + python: python3.13 repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.0.1 @@ -20,13 +20,12 @@ repos: - id: mixed-line-ending exclude: .idea/.* - id: check-json - - repo: https://github.com/ambv/black - rev: 23.3.0 - hooks: - - id: black - language_version: python3.10 - - repo: https://github.com/pycqa/flake8 - rev: 5.0.4 - hooks: - - id: flake8 - language_version: python3.10 + - repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.7.3 + hooks: + # Run the linter. + - id: ruff + args: [ --fix ] + # Run the formatter. + - id: ruff-format diff --git a/appsearch/ormutils.py b/appsearch/ormutils.py index 43f1415..93c565a 100644 --- a/appsearch/ormutils.py +++ b/appsearch/ormutils.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- """ormutils.py: ORM Utils""" + from functools import reduce from django.core.exceptions import FieldDoesNotExist diff --git a/appsearch/registry.py b/appsearch/registry.py index f93b117..138aa84 100644 --- a/appsearch/registry.py +++ b/appsearch/registry.py @@ -361,9 +361,9 @@ def get_searchable_field_choices(self, include_types=False): # noqa: E731 choices = map(lambda c: c + (self.get_field_classification(c[0]),), choices) # Perform a sha hash on the ORM path to get something unique and obscured for the frontend - encode_value = lambda pair: ( # noqa: E731 - (sha((",".join(pair[0])).encode("utf-8")).hexdigest(),) + tuple(pair[1:]) - ) + def encode_value(pair): + return (sha(",".join(pair[0]).encode("utf-8")).hexdigest(),) + tuple(pair[1:]) + return map(encode_value, choices) def reverse_field_hash(self, hash): diff --git a/appsearch/tests.py b/appsearch/tests.py index 9baad18..e0156ce 100644 --- a/appsearch/tests.py +++ b/appsearch/tests.py @@ -5,6 +5,7 @@ Replace this with more appropriate tests for your application. """ + import re from urllib.parse import urlencode diff --git a/demo_app/company/search.py b/demo_app/company/search.py index 776fecc..b5a8559 100644 --- a/demo_app/company/search.py +++ b/demo_app/company/search.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- """search.py: Django company""" - from appsearch.registry import ModelSearch, search from .models import Company diff --git a/demo_app/users/search.py b/demo_app/users/search.py index 3d2f6d1..7cd5e6c 100644 --- a/demo_app/users/search.py +++ b/demo_app/users/search.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -"""search.py: Django """ - +"""search.py: Django""" import logging diff --git a/demo_app/users/views.py b/demo_app/users/views.py index 0471e03..220b364 100644 --- a/demo_app/users/views.py +++ b/demo_app/users/views.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -"""views.py.py: """ - +"""views.py.py:""" from django.contrib.auth import get_user_model diff --git a/pyproject.toml b/pyproject.toml index 7bab7b8..1042b06 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,6 +26,7 @@ classifiers = [ "Programming Language :: Python", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Topic :: Utilities", ] dependencies = [