Skip to content

Commit 63d6b03

Browse files
committed
chores: Update checks and tests and supported versions
Update the test matrix to include the latest supported version of Python and Django, and remove versions that are not supported anymore. Add `isort` and `bandit` to the checks and update checks and test configuration.
1 parent b664e25 commit 63d6b03

File tree

24 files changed

+173
-86
lines changed

24 files changed

+173
-86
lines changed

.github/workflows/tests_and_publish.yml

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,31 @@ jobs:
2424
- name: Setup Python
2525
uses: actions/setup-python@master
2626
with:
27-
python-version: '3.11'
27+
python-version: '3.12'
2828

2929
- name: Install packages
30-
run: pip install -r develop_requirements.txt
30+
run: pip install -r requirements_dev.txt
3131

3232
- name: Black
3333
run: |
34-
black --check -l 120 django_opensearch_dsl tests
34+
black --check -l 120 django_opensearch_dsl/ tests/
35+
36+
isort:
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v2
40+
41+
- name: Setup Python
42+
uses: actions/setup-python@master
43+
with:
44+
python-version: '3.12'
45+
46+
- name: Install packages
47+
run: pip install -r requirements_dev.txt
48+
49+
- name: Isort
50+
run: |
51+
isort --check django_opensearch_dsl/ tests/
3552
3653
pycodestyle:
3754
runs-on: ubuntu-latest
@@ -41,14 +58,14 @@ jobs:
4158
- name: Setup Python
4259
uses: actions/setup-python@master
4360
with:
44-
python-version: '3.11'
61+
python-version: '3.12'
4562

4663
- name: Install packages
47-
run: pip install -r develop_requirements.txt
64+
run: pip install -r requirements_dev.txt
4865

4966
- name: Pycodestyle
5067
run: |
51-
pycodestyle django_opensearch_dsl tests
68+
pycodestyle django_opensearch_dsl/ tests/
5269
5370
pydocstyle:
5471
runs-on: ubuntu-latest
@@ -58,29 +75,44 @@ jobs:
5875
- name: Setup Python
5976
uses: actions/setup-python@master
6077
with:
61-
python-version: '3.11'
78+
python-version: '3.12'
6279

6380
- name: Install packages
64-
run: pip install -r develop_requirements.txt
81+
run: pip install -r requirements_dev.txt
6582

6683
- name: Pydocstyle
6784
run: |
68-
pydocstyle --count django_opensearch_dsl tests
85+
pydocstyle --count django_opensearch_dsl/ tests/
86+
87+
bandit:
88+
runs-on: ubuntu-latest
89+
steps:
90+
- uses: actions/checkout@v2
91+
92+
- name: Setup Python
93+
uses: actions/setup-python@master
94+
with:
95+
python-version: '3.12'
96+
97+
- name: Install packages
98+
run: pip install -r requirements_dev.txt
99+
100+
- name: Bandit
101+
run: |
102+
bandit --ini=setup.cfg -ll 2> /dev/null
69103
70104
71105
test:
72-
needs: [black, pycodestyle, pydocstyle]
106+
needs: [black, isort, pycodestyle, pydocstyle, bandit]
73107
runs-on: ubuntu-latest
74108
strategy:
75109
matrix:
76-
python-version: [ 3.7, 3.8, 3.9, '3.10', '3.11']
77-
django-version: [ 32, 40, 41 ]
110+
python-version: [ 3.9, '3.10', '3.11', '3.12']
111+
django-version: [ 32, 42, 50 ]
78112
opensearch-version: [ 10, 20 ]
79113
exclude:
80-
- python-version: 3.7
81-
django-version: 40
82-
- python-version: 3.7
83-
django-version: 41
114+
- python-version: 3.9
115+
django-version: 50
84116

85117
steps:
86118
- uses: actions/checkout@v2

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ Ready to contribute? Here's how to set up `django-opensearch-dsl` for local deve
5858
```bash
5959
python3 -m venv venv
6060
source venv/bin/activate
61-
pip3 install -r develop_requirements.txt
61+
pip3 install -r requirements.txt
62+
pip3 install -r requirements_dev.txt
6263
```
6364

6465
4. Create a branch for local development:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Django Opensearch DSL
44
[![PyPI Version](https://badge.fury.io/py/django-opensearch-dsl.svg)](https://badge.fury.io/py/django-opensearch-dsl)
55
[![Documentation Status](https://readthedocs.org/projects/django-opensearch-dsl/badge/?version=latest)](https://django-opensearch-dsl.readthedocs.io/en/latest/?badge=latest)
66
![Tests](https://github.com/Codoc-os/django-opensearch-dsl/workflows/Tests/badge.svg)
7-
[![Python 3.7+](https://img.shields.io/badge/Python-3.7+-brightgreen.svg)](#)
7+
[![Python 3.9+](https://img.shields.io/badge/Python-3.9+-brightgreen.svg)](#)
88
[![Django 3.2+](https://img.shields.io/badge/Django-3.2+-brightgreen.svg)](#)
99
[![OpenSearch 1.3+, 2.7+](https://img.shields.io/badge/OpenSearch-1.3+-brightgreen.svg)](#)
1010
[![License Apache 2](https://img.shields.io/badge/license-Apache%202-brightgreen.svg)](https://github.com/Codoc-os/django-opensearch-dsl/blob/master/LICENSE)

bin/pre_commit.sh

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,33 @@
11
#!/bin/bash
22

33
BASE_PATH="$(dirname "$0")"
4-
54
source "$BASE_PATH/colors.sh"
6-
75
EXIT_CODE=0
86

7+
8+
################################################################################
9+
# ISORT #
10+
################################################################################
11+
echo -n "${Cyan}Formatting import with isort... $Color_Off"
12+
out=$(isort django_opensearch_dsl/ tests/)
13+
if [ ! -z "$out" ] ; then
14+
echo ""
15+
echo -e "$out"
16+
fi
17+
echo "${Green}Ok ✅ $Color_Off"
18+
echo ""
19+
20+
################################################################################
21+
# BLACK #
22+
################################################################################
923
echo "${Cyan}Formatting code with black...$Color_Off"
10-
black -l 120 django_opensearch_dsl tests
24+
black -l 120 django_opensearch_dsl/ tests/
1125
echo ""
1226

27+
28+
################################################################################
29+
# PYCODESTYLE #
30+
################################################################################
1331
echo -n "${Cyan}Running pycodestyle... $Color_Off"
1432
out=$(pycodestyle django_opensearch_dsl tests)
1533
if [ "$?" -ne 0 ] ; then
@@ -22,9 +40,27 @@ fi
2240
echo ""
2341

2442

43+
################################################################################
44+
# PYDOCSTYLE #
45+
################################################################################
2546
echo -n "${Cyan}Running pydocstyle... $Color_Off"
26-
out=$(pydocstyle --count django_opensearch_dsl tests)
27-
if [ "${PIPESTATUS[0]}" -ne 0 ] ; then
47+
out=$(pydocstyle --count django_opensearch_dsl/ tests/)
48+
if [ "$?" -ne 0 ] ; then
49+
echo "${Red}Error !$Color_Off"
50+
echo -e "$out"
51+
EXIT_CODE=1
52+
else
53+
echo "${Green}Ok ✅ $Color_Off"
54+
fi
55+
echo ""
56+
57+
58+
################################################################################
59+
# BANDIT #
60+
################################################################################
61+
echo -n "${Cyan}Running bandit... $Color_Off"
62+
out=$(bandit --ini=setup.cfg -ll 2> /dev/null)
63+
if [ "$?" -ne 0 ] ; then
2864
echo "${Red}Error !$Color_Off"
2965
echo -e "$out"
3066
EXIT_CODE=1
@@ -34,6 +70,10 @@ fi
3470
echo ""
3571

3672

73+
74+
################################################################################
75+
76+
3777
if [ $EXIT_CODE = 1 ] ; then
3878
echo "${Red}⚠ You must fix the errors before committing ⚠$Color_Off"
3979
exit $EXIT_CODE

develop_requirements.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

django_opensearch_dsl/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import django
2-
32
from django.utils.module_loading import autodiscover_modules
43

54
from .documents import Document # noqa

django_opensearch_dsl/apps.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from django.apps import AppConfig
22
from django.conf import settings
33
from django.utils.module_loading import import_string
4-
54
from opensearchpy.connection.connections import connections
65

76

django_opensearch_dsl/documents.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
import time
44
from collections import deque
55
from functools import partial
6-
from typing import Optional, Iterable
6+
from typing import Iterable, Optional
77

88
from django.db import models
9-
from django.db.models import QuerySet, Q
10-
from opensearchpy.helpers.document import Document as DSLDocument
9+
from django.db.models import Q, QuerySet
1110
from opensearchpy.helpers import bulk, parallel_bulk
11+
from opensearchpy.helpers.document import Document as DSLDocument
1212

1313
from . import fields
1414
from .apps import DODConfig
@@ -210,7 +210,7 @@ def _get_actions(self, object_list, action):
210210
yield self._prepare_action(object_instance, action)
211211

212212
def _bulk(self, *args, parallel=False, using=None, **kwargs):
213-
"""Helper for switching between normal and parallel bulk operation."""
213+
"""Allow switching between normal and parallel bulk operation."""
214214
if parallel:
215215
return self.parallel_bulk(*args, using=using, **kwargs)
216216
return self.bulk(*args, using=using, **kwargs)

django_opensearch_dsl/management/commands/opensearch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from django.db.models import Q
1616

1717
from django_opensearch_dsl.registries import registry
18+
1819
from ..enums import OpensearchAction
1920
from ..types import parse
2021

django_opensearch_dsl/management/types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import datetime
2-
from typing import Union, List
2+
from typing import List, Union
33

44
from dateutil.parser import isoparse
55
from django.conf import settings
6-
from django.utils.timezone import make_aware, is_aware
6+
from django.utils.timezone import is_aware, make_aware
77

88
Nothing = type(Ellipsis)
99
Values = Union[None, int, float, datetime.datetime, str, List["Values"]]

0 commit comments

Comments
 (0)