Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 23 additions & 29 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ jobs:
fail-fast: false
matrix:
python-version:
- 3.9
- '3.9'
- '3.10'
- 3.11
- '3.11'
- '3.12'
- '3.13'
steps:
- uses: actions/checkout@v2
with:
# Fetch all history instead of the latest commit
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ matrix.python-version }}
# Install dev dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r test_requirements.txt
run: uv sync --locked
- name: Run pre-commit checks
run: pre-commit run --all-files
run: uv run pre-commit run --all-files
- name: Test with pytest
run: pytest --junitxml=test-reports/test-results.xml
run: uv run pytest --junitxml=test-reports/test-results.xml
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action/composite@v1
if: github.event_name == 'push' && always()
Expand All @@ -48,15 +48,15 @@ jobs:
with:
# Fetch all history instead of the latest commit
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Write version file
run: python scripts/write-version.py
run: uv sync --locked
- name: Get current version
id: version-number
run: echo "CURRENT_VERSION=$( python -c 'from dysql.version import __version__; print(__version__)' )" >> $GITHUB_OUTPUT
run: echo "CURRENT_VERSION=$(uv version --short).$(git rev-list --count HEAD)" >> $GITHUB_OUTPUT
- name: Print current version
run: echo CURRENT_VERSION ${{ steps.version-number.outputs.CURRENT_VERSION }}
tag-commit:
Expand All @@ -79,25 +79,19 @@ jobs:
with:
# Fetch all history instead of the latest commit
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install wheel build
- name: Remove version file
# This is just in case something else created it, destroy it to get a fresh version
run: rm -f dysql/version.py
- name: Write version file
run: python scripts/write-version.py
run: uv sync --locked
- name: Set version
run: uv version --no-sync "$(uv version --short).$(git rev-list --count HEAD)"
- name: Build
run: python -m build
run: uv build
- name: Check upload
# packaging needs updating due to https://github.com/pypa/twine/issues/1216
run: pip install -U twine packaging && twine check dist/*
run: uv run --with twine twine check dist/*
- name: Publish to PyPi
uses: pypa/gh-action-pypi-publish@release/v1
# Only publish on pushes to main
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ dist/
*.swp
pytest_cache

dysql/version.py
docker-compose.env
docker-compose.yml
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.7
rev: v0.12.7
hooks:
# Run the linter.
- id: ruff
- id: ruff-check
args: [ --fix ]
# Run the formatter.
- id: ruff-format
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.11.4
3.11
16 changes: 12 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ FROM python:${python_version}-alpine

RUN apk add gcc musl-dev libffi-dev openssl-dev git

COPY requirements.txt /tmp/
COPY test_requirements.txt /tmp/
COPY setup.py /tmp/
RUN cd /tmp && pip install -r /tmp/requirements.txt -r /tmp/test_requirements.txt
WORKDIR /app

# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/

# Install dependencies first to leverage Docker cache
COPY pyproject.toml uv.lock README.rst /app/
RUN uv sync --locked --no-install-project --no-dev

# Install the project separately for optimal layer caching
COPY dysql /app/dysql
RUN uv sync --locked --no-dev
9 changes: 9 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ Installation

pip install dy-sql

Development Setup
=================

To set up the development environment:

.. code-block::

uv sync

Component Breakdown
===================
* **set_default_connection_parameters** - this function needs to be used to set the database parameters on
Expand Down
1 change: 1 addition & 0 deletions dysql/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
with the terms of the Adobe license agreement accompanying it.
"""

import logging
import functools
import inspect
Expand Down
1 change: 1 addition & 0 deletions dysql/pydantic_mappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
with the terms of the Adobe license agreement accompanying it.
"""

from typing import Any, Dict, Set

import sqlalchemy
Expand Down
3 changes: 2 additions & 1 deletion dysql/query_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
with the terms of the Adobe license agreement accompanying it.
"""

import re

from typing import Iterable, Optional, Tuple, Union
Expand Down Expand Up @@ -254,7 +255,7 @@ def __validate_keys_clean_query(query, template_params):
validated_keys = []
for groups in re.findall(LIST_TEMPLATE_REGEX, query):
# check first group for the full key
key = f'{groups[2]}__{groups[3] if groups[3] else ""}{groups[4]}'
key = f"{groups[2]}__{groups[3] if groups[3] else ''}{groups[4]}"
validated_keys.append(key)
missing_keys = []

Expand Down
1 change: 1 addition & 0 deletions dysql/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
with the terms of the Adobe license agreement accompanying it.
"""

from unittest.mock import Mock, patch
import pytest

Expand Down
1 change: 1 addition & 0 deletions dysql/test/test_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
with the terms of the Adobe license agreement accompanying it.
"""

from typing import List, Union

import pytest
Expand Down
1 change: 1 addition & 0 deletions dysql/test/test_database_initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
with the terms of the Adobe license agreement accompanying it.
"""

# pylint: disable=protected-access
import sys
from unittest import mock
Expand Down
1 change: 1 addition & 0 deletions dysql/test/test_mappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
with the terms of the Adobe license agreement accompanying it.
"""

import pytest

from dysql import (
Expand Down
1 change: 1 addition & 0 deletions dysql/test/test_mariadbmap_tojson.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
with the terms of the Adobe license agreement accompanying it.
"""

import json
import pytest

Expand Down
1 change: 1 addition & 0 deletions dysql/test/test_pydantic_mappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
with the terms of the Adobe license agreement accompanying it.
"""

import json
from typing import Any, Dict, List, Set, Optional
import pytest
Expand Down
1 change: 1 addition & 0 deletions dysql/test/test_sql_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
with the terms of the Adobe license agreement accompanying it.
"""

import pytest

from dysql import (
Expand Down
1 change: 1 addition & 0 deletions dysql/test/test_sql_exists_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
with the terms of the Adobe license agreement accompanying it.
"""

from unittest.mock import Mock

import pytest
Expand Down
1 change: 1 addition & 0 deletions dysql/test/test_sql_in_list_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
with the terms of the Adobe license agreement accompanying it.
"""

# pylint: disable=too-many-public-methods
import pytest

Expand Down
1 change: 1 addition & 0 deletions dysql/test/test_sql_insert_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
with the terms of the Adobe license agreement accompanying it.
"""

import pytest

import dysql
Expand Down
1 change: 1 addition & 0 deletions dysql/test/test_template_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
with the terms of the Adobe license agreement accompanying it.
"""

import pytest

from dysql.query_utils import TemplateGenerators, ListTemplateException
Expand Down
1 change: 1 addition & 0 deletions dysql/test_managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
with the terms of the Adobe license agreement accompanying it.
"""

import abc
import logging
import os
Expand Down
47 changes: 38 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = ["setuptools>=42", "wheel"]
build-backend = "setuptools.build_meta"
requires = ["uv_build"]
build-backend = "uv_build"

[project]
name = "dy-sql"
Expand All @@ -12,13 +12,42 @@ authors = [
{name = "Adobe", email = "noreply@adobe.com"}
]
urls = { "Homepage" = "https://github.com/adobe/dy-sql" }
version = "3.1"
dependencies = [
# SQLAlchemy 2+ is not yet supported
"sqlalchemy<2",
# now using features only found in pydantic 2+
"pydantic>=2",
]

[dependency-groups]
dev = [
"pytest>=6.2.4",
"pytest-randomly>=3.10.1",
"pytest-cov>=2.12.1",
"ruff>=0.12.7",
"ruff-lsp>=0.0.45",
"pre-commit>=3.6",
"docker>=7",
]

[tool.uv.build-backend]
module-name = "dysql"
module-root = ""
source-exclude = ["dysql/test"]
wheel-exclude = ["dysql/test"]

dynamic = ["version", "dependencies", "optional-dependencies"]
[tool.ruff.lint]
# Enable the copyright rule
preview = true
extend-select = ["CPY"]

[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}
optional-dependencies = {test = { file = ["test_requirements.txt"] }}
version = {attr = "dysql.version.__version__"}
[tool.ruff.lint.flake8-copyright]
min-file-size = 200
notice-rgx = '''"""
Copyright [(2)\d{3}]* Adobe
All Rights Reserved.

[tool.setuptools.packages.find]
exclude = ["*.tests", "*.tests.*", "tests.*", "tests"]
NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
with the terms of the Adobe license agreement accompanying it.
"""'''
2 changes: 0 additions & 2 deletions pytest.ini

This file was deleted.

4 changes: 0 additions & 4 deletions requirements.txt

This file was deleted.

19 changes: 0 additions & 19 deletions ruff.toml

This file was deleted.

Loading