diff --git a/.ambient-package-update/metadata.py b/.ambient-package-update/metadata.py index 4e8d4c4..a0a390b 100644 --- a/.ambient-package-update/metadata.py +++ b/.ambient-package-update/metadata.py @@ -1,5 +1,10 @@ from ambient_package_update.metadata.author import PackageAuthor -from ambient_package_update.metadata.constants import DEV_DEPENDENCIES, LICENSE_GPL +from ambient_package_update.metadata.constants import ( + DEV_DEPENDENCIES, + LICENSE_GPL, + SUPPORTED_DJANGO_VERSIONS, + SUPPORTED_PYTHON_VERSIONS, +) from ambient_package_update.metadata.package import PackageMetadata from ambient_package_update.metadata.readme import ReadmeContent from ambient_package_update.metadata.ruff_ignored_inspection import RuffIgnoredInspection @@ -46,6 +51,8 @@ 'Django>=3.2', 'html2text>=2020.1.16', ], + supported_django_versions=SUPPORTED_DJANGO_VERSIONS, + supported_python_versions=SUPPORTED_PYTHON_VERSIONS, optional_dependencies={ 'dev': [ *DEV_DEPENDENCIES, diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 930c6d6..9c34bf3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,10 +8,10 @@ jobs: linting: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python 3.12 - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: python-version: "3.12" @@ -21,13 +21,13 @@ jobs: - name: Run pre-commit hooks run: pre-commit run --all-files --hook-stage push - build: + tests: name: Python ${{ matrix.python-version }}, django ${{ matrix.django-version }} runs-on: ubuntu-22.04 strategy: matrix: - python-version: [3.8, 3.9, '3.10', '3.11', '3.12'] - django-version: [32, 41, 42] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', ] + django-version: ['32', '41', '42', ] exclude: - python-version: '3.12' @@ -38,9 +38,9 @@ jobs: django-version: 32 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: setup python - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install tox @@ -49,3 +49,40 @@ jobs: env: TOXENV: django${{ matrix.django-version }} run: tox + - name: Upload coverage data + uses: actions/upload-artifact@v3 + with: + name: coverage-data + path: '.coverage*' + + coverage: + name: Coverage + runs-on: ubuntu-22.04 + needs: tests + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v4 + with: + python-version: '3.12' + + - name: Install dependencies + run: python -m pip install --upgrade coverage[toml] + + - name: Download data + uses: actions/download-artifact@v3 + with: + name: coverage-data + + - name: Combine coverage and fail if it's <100% + run: | + # python -m coverage combine + python -m coverage html --skip-covered --skip-empty + python -m coverage report --fail-under=100 + + - name: Upload HTML report + if: ${{ failure() }} + uses: actions/upload-artifact@v3 + with: + name: html-report + path: htmlcov diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0fd048d..1c3cffc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,20 +3,20 @@ repos: - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.9.1 + rev: 23.10.0 hooks: - id: black args: [ --check, --diff, --config, ./pyproject.toml ] stages: [ push ] - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: 'v0.0.292' + rev: 'v0.1.1' hooks: - id: ruff - args: [ --fix, --exit-non-zero-on-fix ] + args: [ --fix, --unsafe-fixes, --exit-non-zero-on-fix ] - repo: https://github.com/asottile/pyupgrade - rev: v3.14.0 + rev: v3.15.0 hooks: - id: pyupgrade args: [ --py38-plus ] diff --git a/CHANGES.md b/CHANGES.md index cad3c9b..0cacafe 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Changelog +* *1.2.3** (2023-10-20) + * Linter updaters including code adjustments + * Updates from ambient updater + * *1.2.2** (2023-10-04) * Dependency to ambient updater updated diff --git a/README.md b/README.md index f92fae0..a469bfb 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ [![PyPI release](https://img.shields.io/pypi/v/django-pony-express.svg)](https://pypi.org/project/django-pony-express/) [![Downloads](https://static.pepy.tech/badge/django-pony-express)](https://pepy.tech/project/django-pony-express) +[![Coverage](https://img.shields.io/badge/Coverage-100%25-success)](https://github.com/ambient-innovation/django-pony-express/actions?workflow=CI) [![Linting](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![Coding Style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black) [![Documentation Status](https://readthedocs.org/projects/django-pony-express/badge/?version=latest)](https://django-pony-express.readthedocs.io/en/latest/?badge=latest) @@ -80,6 +81,12 @@ Ingenious, right? pytest --ds settings tests ```` +- Check coverage + ```` + coverage run -m pytest --ds settings tests + coverage report -m + ```` + ### Git hooks (via pre-commit) We use pre-push hooks to ensure that only linted code reaches our remote repository and pipelines aren't triggered in diff --git a/django_pony_express/__init__.py b/django_pony_express/__init__.py index 480109f..c91ce1c 100644 --- a/django_pony_express/__init__.py +++ b/django_pony_express/__init__.py @@ -1,3 +1,3 @@ """Class-based emails including a test suite for Django""" -__version__ = '1.2.2' +__version__ = '1.2.3' diff --git a/django_pony_express/services/base.py b/django_pony_express/services/base.py index 6c7d548..5480c50 100644 --- a/django_pony_express/services/base.py +++ b/django_pony_express/services/base.py @@ -188,8 +188,13 @@ def get_translation(self) -> Union[str, None]: """ Tries to fetch the current translation from the django settings. """ + language_str_length = 2 try: - return settings.LANGUAGE_CODE[:2] if settings.LANGUAGE_CODE and len(settings.LANGUAGE_CODE) >= 2 else None + return ( + settings.LANGUAGE_CODE[:2] + if settings.LANGUAGE_CODE and len(settings.LANGUAGE_CODE) >= language_str_length + else None + ) except TypeError: return None diff --git a/django_pony_express/services/tests.py b/django_pony_express/services/tests.py index 641c5ba..a559e7e 100644 --- a/django_pony_express/services/tests.py +++ b/django_pony_express/services/tests.py @@ -78,9 +78,7 @@ def all(self): self.reload() # Load data to matching list - match_list = [] - for email in self._outbox: - match_list.append(email) + match_list = list(self._outbox) return EmailTestServiceQuerySet(matching_list=match_list) diff --git a/pyproject.toml b/pyproject.toml index 9436bf7..f1609bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,14 +41,14 @@ dev = [ 'freezegun~=1.2', 'pytest-django~=4.5', 'pytest-mock~=3.10', - 'pre-commit~=3.2', - 'black~=23.3', - 'Django~=3.2', + 'coverage~=7.3', + 'pre-commit~=3.5', + 'black~=23.10', 'sphinx==4.2.0', 'sphinx-rtd-theme==1.0.0', 'm2r2==0.3.1', 'mistune<2.0.0', - 'ambient-package-update~=23.10.1', + 'ambient-package-update~=23.10.2', ] [tool.flit.module] @@ -88,8 +88,9 @@ select = [ "PIE", # Bunch of useful rules # "SIM", # Simplifies your code "INT", # Validates your gettext translation strings + "PERF", # PerfLint "PGH", # No all-purpose "# noqa" and eval validation - # "UP", # PyUpgrade + "PL", # PyLint ] ignore = [ 'N999', # Project name contains underscore, not fixable @@ -116,8 +117,9 @@ fixable = [ "PIE", # Bunch of useful rules # "SIM", # Simplifies your code "INT", # Validates your gettext translation strings + "PERF", # PerfLint "PGH", # No all-purpose "# noqa" and eval validation - # "UP", # PyUpgrade + "PL", # PyLint ] unfixable = [] @@ -163,12 +165,12 @@ isolated_build = True [testenv] # Django deprecation overview: https://www.djangoproject.com/download/ deps = - django32: Django>=3.2,<3.3 - django41: Django>=4.1,<4.2 - django42: Django>=4.2,<4.3 + django32: Django==3.2.* + django41: Django==4.1.* + django42: Django==4.2.* extras = dev, commands = - pytest --ds settings tests + coverage run -m pytest --ds settings tests [gh-actions] python = diff --git a/scripts/unix/install_requirements.sh b/scripts/unix/install_requirements.sh new file mode 100644 index 0000000..36adaba --- /dev/null +++ b/scripts/unix/install_requirements.sh @@ -0,0 +1,3 @@ +pip install -U pip-tools +pip-compile --extra dev, -o requirements.txt pyproject.toml --resolver=backtracking +pip-sync diff --git a/scripts/windows/install_requirements.ps1 b/scripts/windows/install_requirements.ps1 new file mode 100644 index 0000000..36adaba --- /dev/null +++ b/scripts/windows/install_requirements.ps1 @@ -0,0 +1,3 @@ +pip install -U pip-tools +pip-compile --extra dev, -o requirements.txt pyproject.toml --resolver=backtracking +pip-sync diff --git a/setup.cfg b/setup.cfg index ef803ed..5f27401 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,18 @@ [metadata] description-file = README.md license-file = LICENSE.md + +[coverage:run] +branch = True +parallel = True +source = + django_pony_express + tests + +[coverage:paths] +source = + django_pony_express + .tox/**/site-packages + +[coverage:report] +show_missing = True