From 5759570fd17ca3c945caa332050cbc5f5f7f2ca1 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Wed, 6 Nov 2024 13:17:06 +0100 Subject: [PATCH 01/31] CI: Fix CodeQL and Release jobs --- .github/workflows/codeql.yml | 5 +++-- .github/workflows/release.yml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 9a5eca89..6a23088d 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -28,7 +28,8 @@ jobs: strategy: fail-fast: false - language: [ python ] + matrix: + language: [ python ] steps: - name: Checkout @@ -58,7 +59,7 @@ jobs: - name: Install project run: | - uv pip install --editable=.[test] + uv pip install --system '.[test]' - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b00c58d7..63de61dc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,7 +23,7 @@ jobs: - name: Build package run: | - uv pip install build twine wheel + uv pip install --system build twine wheel python -m build twine check dist/* From 313dd6fe5bad1d6b484c12f33cbd55be65ff8457 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 14:46:15 +0000 Subject: [PATCH 02/31] Update poethepoet requirement from <0.30 to <0.31 Updates the requirements on [poethepoet](https://github.com/nat-n/poethepoet) to permit the latest version. - [Release notes](https://github.com/nat-n/poethepoet/releases) - [Commits](https://github.com/nat-n/poethepoet/compare/v0.1.0...v0.30.0) --- updated-dependencies: - dependency-name: poethepoet dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index ccece82e..b5c87934 100644 --- a/setup.py +++ b/setup.py @@ -67,7 +67,7 @@ def read(path): "certifi", "createcoverage>=1,<2", "mypy<1.14", - "poethepoet<0.30", + "poethepoet<0.31", "ruff<0.8", "stopit>=1.1.2,<2", "tox>=3,<5", From a126030bc3d4e063488f9d922e0ad95bc9f364a4 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Thu, 14 Nov 2024 00:27:06 +0100 Subject: [PATCH 03/31] Python: Fix "implicit namespace packages" migration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... by omitting `__init__.py` from `crate` namespace package altogether, see "PEP 420" [1] and "Package Discovery and Namespace Package » Finding namespace packages" [2]. [1] https://peps.python.org/pep-0420/ [2] https://setuptools.pypa.io/en/latest/userguide/package_discovery.html#namespace-packages --- CHANGES.rst | 5 +++++ src/crate/__init__.py | 0 2 files changed, 5 insertions(+) delete mode 100644 src/crate/__init__.py diff --git a/CHANGES.rst b/CHANGES.rst index 64141cc5..a77fcc1a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,10 @@ Changes for crate Unreleased ========== +- Python: Fixed "implicit namespace packages" migration by omitting + ``__init__.py`` from ``crate`` namespace package, see `PEP 420`_ + and `Package Discovery and Namespace Package » Finding namespace packages`_. + 2024/11/05 1.0.0 ================ @@ -44,6 +48,7 @@ Unreleased .. _Migrate from crate.client to sqlalchemy-cratedb: https://cratedb.com/docs/sqlalchemy-cratedb/migrate-from-crate-client.html +.. _Package Discovery and Namespace Package » Finding namespace packages: https://setuptools.pypa.io/en/latest/userguide/package_discovery.html#namespace-packages .. _PEP 420: https://peps.python.org/pep-0420/ .. _sqlalchemy-cratedb: https://pypi.org/project/sqlalchemy-cratedb/ diff --git a/src/crate/__init__.py b/src/crate/__init__.py deleted file mode 100644 index e69de29b..00000000 From 69b8b690fe010f2d6c4ecd1124b05253dc0b7834 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Thu, 14 Nov 2024 00:45:21 +0100 Subject: [PATCH 04/31] Chore: Suppress unqualified CodeQL admonitions GitHub's CodeQL flags [1] those spots with "Unused global variable" [2]. Based on a suggestion [3], this patch attempts to use the `advanced-security/dismiss-alerts` [4] GitHub Action recipe to provide measures to suppress CodeQL flagging by using inline code annotations. [1] https://github.com/crate/crate-python/security/code-scanning [2] https://codeql.github.com/codeql-query-help/python/py-unused-global-variable/ [3] Issue 11427 at https://github.com/github/codeql/issues [4] https://github.com/advanced-security/dismiss-alerts --- .github/workflows/codeql.yml | 19 +++++++++++++++++++ src/crate/client/__init__.py | 1 + 2 files changed, 20 insertions(+) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 6a23088d..0e099fca 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -53,6 +53,8 @@ jobs: languages: ${{ matrix.language }} config-file: ./.github/codeql.yml queries: +security-and-quality + # run an 'alert-suppression' query + packs: "codeql/${{ matrix.language }}-queries:AlertSuppression.ql" #- name: Autobuild # uses: github/codeql-action/autobuild@v2 @@ -62,4 +64,21 @@ jobs: uv pip install --system '.[test]' - name: Perform CodeQL Analysis + id: analyze uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{matrix.language}}" + # define the output folder for SARIF files + output: sarif-results + + # Unlock inline mechanism to suppress CodeQL warnings. + # https://github.com/github/codeql/issues/11427#issuecomment-1721059096 + - name: Dismiss alerts + # if: github.ref == 'refs/heads/main' + uses: advanced-security/dismiss-alerts@v1 + with: + # specify a 'sarif-id' and 'sarif-file' + sarif-id: ${{ steps.analyze.outputs.sarif-id }} + sarif-file: sarif-results/${{ matrix.language }}.sarif + env: + GITHUB_TOKEN: ${{ github.token }} diff --git a/src/crate/client/__init__.py b/src/crate/client/__init__.py index 35a53d6e..61a61a88 100644 --- a/src/crate/client/__init__.py +++ b/src/crate/client/__init__.py @@ -31,6 +31,7 @@ # regex! __version__ = "1.0.0" +# codeql[py/unused-global-variable] apilevel = "2.0" threadsafety = 1 paramstyle = "qmark" From 854c1daa201f11fd4a84f596a479ecde42879cb3 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Sat, 23 Nov 2024 13:46:14 +0100 Subject: [PATCH 05/31] CI: Migrate to `astral-sh/setup-uv` --- .github/workflows/codeql.yml | 4 +++- .github/workflows/nightly.yml | 4 +++- .github/workflows/release.yml | 4 +++- .github/workflows/tests.yml | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 0e099fca..ac07837e 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -45,7 +45,9 @@ jobs: setup.py - name: Install uv - uses: yezz123/setup-uv@v4 + uses: astral-sh/setup-uv@v3 + with: + version: "latest" - name: Initialize CodeQL uses: github/codeql-action/init@v3 diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 74b1bdd1..1b9b74e2 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -33,7 +33,9 @@ jobs: cache-dependency-path: 'setup.py' - name: Install uv - uses: yezz123/setup-uv@v4 + uses: astral-sh/setup-uv@v3 + with: + version: "latest" - name: Invoke tests run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 63de61dc..de847c46 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,9 @@ jobs: cache-dependency-path: 'setup.py' - name: Install uv - uses: yezz123/setup-uv@v4 + uses: astral-sh/setup-uv@v3 + with: + version: "latest" - name: Build package run: | diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b7b4f964..6f9b0029 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -48,7 +48,9 @@ jobs: cache-dependency-path: setup.py - name: Install uv - uses: yezz123/setup-uv@v4 + uses: astral-sh/setup-uv@v3 + with: + version: "latest" - name: Invoke tests run: | From b2804d4c9edc7631e8208efb085dd8b4bbc882b7 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Sat, 23 Nov 2024 14:08:05 +0100 Subject: [PATCH 06/31] Release 1.0.1 --- CHANGES.rst | 5 +++++ src/crate/client/__init__.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index a77fcc1a..2cf9c9dd 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,11 @@ Changes for crate Unreleased ========== + + +2024/11/23 1.0.1 +================ + - Python: Fixed "implicit namespace packages" migration by omitting ``__init__.py`` from ``crate`` namespace package, see `PEP 420`_ and `Package Discovery and Namespace Package » Finding namespace packages`_. diff --git a/src/crate/client/__init__.py b/src/crate/client/__init__.py index 61a61a88..2fec7abd 100644 --- a/src/crate/client/__init__.py +++ b/src/crate/client/__init__.py @@ -29,7 +29,7 @@ # version string read from setup.py using a regex. Take care not to break the # regex! -__version__ = "1.0.0" +__version__ = "1.0.1" # codeql[py/unused-global-variable] apilevel = "2.0" From 7665a0af16e6f33ae58f5688dcb95eb3c4419786 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Nov 2024 14:50:24 +0000 Subject: [PATCH 07/31] Update poethepoet requirement from <0.31 to <0.32 Updates the requirements on [poethepoet](https://github.com/nat-n/poethepoet) to permit the latest version. - [Release notes](https://github.com/nat-n/poethepoet/releases) - [Commits](https://github.com/nat-n/poethepoet/compare/v0.1.0...v0.31.0) --- updated-dependencies: - dependency-name: poethepoet dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b5c87934..05ae6fe8 100644 --- a/setup.py +++ b/setup.py @@ -67,7 +67,7 @@ def read(path): "certifi", "createcoverage>=1,<2", "mypy<1.14", - "poethepoet<0.31", + "poethepoet<0.32", "ruff<0.8", "stopit>=1.1.2,<2", "tox>=3,<5", From 0e9873f57b8f84f31f376e9ada2df5f68fdec960 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Dec 2024 14:53:53 +0000 Subject: [PATCH 08/31] Bump codecov/codecov-action from 4 to 5 Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4 to 5. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v4...v5) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6f9b0029..045ada7a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -75,7 +75,7 @@ jobs: # https://github.com/codecov/codecov-action - name: Upload coverage results to Codecov - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v5 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} with: From d29f0cac3a7329607b8c0556f85588735f95de41 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Dec 2024 14:53:58 +0000 Subject: [PATCH 09/31] Bump astral-sh/setup-uv from 3 to 4 Bumps [astral-sh/setup-uv](https://github.com/astral-sh/setup-uv) from 3 to 4. - [Release notes](https://github.com/astral-sh/setup-uv/releases) - [Commits](https://github.com/astral-sh/setup-uv/compare/v3...v4) --- updated-dependencies: - dependency-name: astral-sh/setup-uv dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql.yml | 2 +- .github/workflows/nightly.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/tests.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index ac07837e..84d277ce 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -45,7 +45,7 @@ jobs: setup.py - name: Install uv - uses: astral-sh/setup-uv@v3 + uses: astral-sh/setup-uv@v4 with: version: "latest" diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 1b9b74e2..d852e321 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -33,7 +33,7 @@ jobs: cache-dependency-path: 'setup.py' - name: Install uv - uses: astral-sh/setup-uv@v3 + uses: astral-sh/setup-uv@v4 with: version: "latest" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index de847c46..8db1ab52 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ jobs: cache-dependency-path: 'setup.py' - name: Install uv - uses: astral-sh/setup-uv@v3 + uses: astral-sh/setup-uv@v4 with: version: "latest" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 045ada7a..818feba8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -48,7 +48,7 @@ jobs: cache-dependency-path: setup.py - name: Install uv - uses: astral-sh/setup-uv@v3 + uses: astral-sh/setup-uv@v4 with: version: "latest" From 11a391a9a92228d226295ef94a95b4c6526b32e6 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Fri, 13 Dec 2024 18:48:33 +0100 Subject: [PATCH 10/31] CI: Provide Python 3.7. EOL, it was removed from recent GHA runners --- .github/workflows/nightly.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index d852e321..7f9e05b6 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -14,7 +14,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: ['ubuntu-latest'] + os: ['ubuntu-22.04'] python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] cratedb-version: ['nightly'] From 1b7048b9af553f251ae25249a590e41947b8dd74 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Dec 2024 14:37:38 +0000 Subject: [PATCH 11/31] Chore(deps-dev): Update mypy requirement from <1.14 to <1.15 Updates the requirements on [mypy](https://github.com/python/mypy) to permit the latest version. - [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md) - [Commits](https://github.com/python/mypy/compare/v0.1.0...v1.14.0) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 05ae6fe8..27851cab 100644 --- a/setup.py +++ b/setup.py @@ -66,7 +66,7 @@ def read(path): 'backports.zoneinfo<1; python_version<"3.9"', "certifi", "createcoverage>=1,<2", - "mypy<1.14", + "mypy<1.15", "poethepoet<0.32", "ruff<0.8", "stopit>=1.1.2,<2", From 026f5c34d90a45b34391b2bf5b43dc97f3acea1a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Dec 2024 14:39:00 +0000 Subject: [PATCH 12/31] Chore(deps-dev): Update poethepoet requirement from <0.32 to <0.33 Updates the requirements on [poethepoet](https://github.com/nat-n/poethepoet) to permit the latest version. - [Release notes](https://github.com/nat-n/poethepoet/releases) - [Commits](https://github.com/nat-n/poethepoet/compare/v0.1.0...v0.32.0) --- updated-dependencies: - dependency-name: poethepoet dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 27851cab..e842cc03 100644 --- a/setup.py +++ b/setup.py @@ -67,7 +67,7 @@ def read(path): "certifi", "createcoverage>=1,<2", "mypy<1.15", - "poethepoet<0.32", + "poethepoet<0.33", "ruff<0.8", "stopit>=1.1.2,<2", "tox>=3,<5", From b4a2ed4f623e86c7508467c8de61fed7152cabcf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Jan 2025 14:30:59 +0000 Subject: [PATCH 13/31] Chore(deps): Bump astral-sh/setup-uv from 4 to 5 Bumps [astral-sh/setup-uv](https://github.com/astral-sh/setup-uv) from 4 to 5. - [Release notes](https://github.com/astral-sh/setup-uv/releases) - [Commits](https://github.com/astral-sh/setup-uv/compare/v4...v5) --- updated-dependencies: - dependency-name: astral-sh/setup-uv dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql.yml | 2 +- .github/workflows/nightly.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/tests.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 84d277ce..da5cb5cc 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -45,7 +45,7 @@ jobs: setup.py - name: Install uv - uses: astral-sh/setup-uv@v4 + uses: astral-sh/setup-uv@v5 with: version: "latest" diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 7f9e05b6..cd5fa37f 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -33,7 +33,7 @@ jobs: cache-dependency-path: 'setup.py' - name: Install uv - uses: astral-sh/setup-uv@v4 + uses: astral-sh/setup-uv@v5 with: version: "latest" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8db1ab52..eca585dc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ jobs: cache-dependency-path: 'setup.py' - name: Install uv - uses: astral-sh/setup-uv@v4 + uses: astral-sh/setup-uv@v5 with: version: "latest" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 818feba8..16ed304a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -48,7 +48,7 @@ jobs: cache-dependency-path: setup.py - name: Install uv - uses: astral-sh/setup-uv@v4 + uses: astral-sh/setup-uv@v5 with: version: "latest" From c6892d5f57104177da1502941cceb73e815fc5ff Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Jan 2025 14:31:02 +0000 Subject: [PATCH 14/31] Chore(deps): Bump advanced-security/dismiss-alerts from 1 to 2 Bumps [advanced-security/dismiss-alerts](https://github.com/advanced-security/dismiss-alerts) from 1 to 2. - [Commits](https://github.com/advanced-security/dismiss-alerts/compare/v1...v2) --- updated-dependencies: - dependency-name: advanced-security/dismiss-alerts dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index da5cb5cc..6d0f4436 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -77,7 +77,7 @@ jobs: # https://github.com/github/codeql/issues/11427#issuecomment-1721059096 - name: Dismiss alerts # if: github.ref == 'refs/heads/main' - uses: advanced-security/dismiss-alerts@v1 + uses: advanced-security/dismiss-alerts@v2 with: # specify a 'sarif-id' and 'sarif-file' sarif-id: ${{ steps.analyze.outputs.sarif-id }} From 4820f8f0696f75500a82667aeb33876276f4f936 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Wed, 15 Jan 2025 23:37:35 +0100 Subject: [PATCH 15/31] Chore: Fix test case because https://example.org/ responds differently --- docs/by-example/http.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/by-example/http.rst b/docs/by-example/http.rst index aacf3481..5afd3dee 100644 --- a/docs/by-example/http.rst +++ b/docs/by-example/http.rst @@ -228,7 +228,7 @@ When connecting to non-CrateDB servers, the HttpClient will raise a ConnectionEr >>> http_client.server_infos(http_client._get_server()) Traceback (most recent call last): ... - crate.client.exceptions.ProgrammingError: Invalid server response of content-type 'text/html; charset=UTF-8': + crate.client.exceptions.ProgrammingError: Invalid server response of content-type 'text/html': ... >>> http_client.close() From 4d47a267097517e612f829e6c046116f20e80fdd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 14:47:42 +0000 Subject: [PATCH 16/31] Chore(deps-dev): Update ruff requirement from <0.8 to <0.10 Updates the requirements on [ruff](https://github.com/astral-sh/ruff) to permit the latest version. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/v0.0.18...0.9.1) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index e842cc03..4da8be94 100644 --- a/setup.py +++ b/setup.py @@ -68,7 +68,7 @@ def read(path): "createcoverage>=1,<2", "mypy<1.15", "poethepoet<0.33", - "ruff<0.8", + "ruff<0.10", "stopit>=1.1.2,<2", "tox>=3,<5", "pytz", From a2aae9bcb7c374ea3e54623ff73ddb2e8e3cde53 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Wed, 15 Jan 2025 22:54:21 +0100 Subject: [PATCH 17/31] Chore: Format code using Ruff 0.9 --- pyproject.toml | 7 +++++++ src/crate/client/http.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 31717680..08b0d321 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,6 +71,13 @@ lint.per-file-ignores."tests/*" = [ "S106", # Possible hardcoded password assigned to argument: "password" "S311", # Standard pseudo-random generators are not suitable for cryptographic purposes ] +lint.per-file-ignores."src/crate/client/{connection.py,http.py}" = [ + "A004", # Import `ConnectionError` is shadowing a Python builtin + "A005", # Import `ConnectionError` is shadowing a Python builtin +] +lint.per-file-ignores."tests/client/test_http.py" = [ + "A004", # Import `ConnectionError` is shadowing a Python builtin +] # =================== diff --git a/src/crate/client/http.py b/src/crate/client/http.py index d9a0598f..e2c164d9 100644 --- a/src/crate/client/http.py +++ b/src/crate/client/http.py @@ -670,7 +670,7 @@ def _drop_server(self, server, message): # if this is the last server raise exception, otherwise try next if not self._active_servers: raise ConnectionError( - ("No more Servers available, " "exception from last server: %s") + ("No more Servers available, exception from last server: %s") % message ) From b44ca897cde9012bc3433d30ff5bcac5025ca8d6 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Thu, 23 Jan 2025 12:59:31 +0100 Subject: [PATCH 18/31] Remove tox, recommend uv tox has been popular in times when it was easier to run a full Python test matrix on your workstation, for example supported by `pyenv`, compared to provisioning and maintaining it on a Jenkins CI runner. Nowadays, it became so easy to run the full-version test matrix on GitHub Actions (GHA), so `tox` became obsolete in such environments that heavily use GHA. Now that recent advancements added `uv` to the table, sandbox environments don't need to feel ousted. --- DEVELOP.rst | 21 +++++++++------------ setup.py | 1 - tox.ini | 14 -------------- 3 files changed, 9 insertions(+), 27 deletions(-) delete mode 100644 tox.ini diff --git a/DEVELOP.rst b/DEVELOP.rst index 85dfb6f7..2f39ede0 100644 --- a/DEVELOP.rst +++ b/DEVELOP.rst @@ -5,7 +5,7 @@ CrateDB Python developer guide Setup ===== -Optionally install Python package and project manager ``uv``, +Optionally install Python package and project manager `uv`_, in order to significantly speed up the package installation:: {apt,brew,pip,zypper} install uv @@ -67,16 +67,11 @@ To inspect the whole list of test cases, run:: bin/test --list-tests -You can run the tests against multiple Python interpreters with `tox`_:: - - tox - -To do this, you will need the respective Python interpreter versions available -on your ``$PATH``. - -To run against a single interpreter, you can also invoke:: - - tox -e py37 +The CI setup on GitHub Actions (GHA) provides a full test matrix covering +relevant Python versions. You can invoke the software tests against a specific +Python interpreter or multiple `Python versions`_ on your workstation using +`uv`_, by supplying the ``--python`` command-line option, or by defining the +`UV_PYTHON`_ environment variable prior to invoking ``source bootstrap.sh``. *Note*: Before running the tests, make sure to stop all CrateDB instances which are listening on the default CrateDB transport port to avoid side effects with @@ -168,12 +163,14 @@ nothing special you need to do to get the live docs to update. .. _@crate/docs: https://github.com/orgs/crate/teams/docs .. _buildout: https://pypi.python.org/pypi/zc.buildout .. _PyPI: https://pypi.python.org/pypi +.. _Python versions: https://docs.astral.sh/uv/concepts/python-versions/ .. _Read the Docs: http://readthedocs.org .. _ReStructuredText: http://docutils.sourceforge.net/rst.html .. _Sphinx: http://sphinx-doc.org/ .. _tests/assets/pki/*.pem: https://github.com/crate/crate-python/tree/main/tests/assets/pki -.. _tox: http://testrun.org/tox/latest/ .. _twine: https://pypi.python.org/pypi/twine .. _useful command-line options for zope-testrunner: https://pypi.org/project/zope.testrunner/#some-useful-command-line-options-to-get-you-started +.. _uv: https://docs.astral.sh/uv/ +.. _UV_PYTHON: https://docs.astral.sh/uv/configuration/environment/#uv_python .. _versions hosted on ReadTheDocs: https://readthedocs.org/projects/crate-python/versions/ .. _zope.testrunner: https://pypi.org/project/zope.testrunner/ diff --git a/setup.py b/setup.py index 4da8be94..0892ed3a 100644 --- a/setup.py +++ b/setup.py @@ -70,7 +70,6 @@ def read(path): "poethepoet<0.33", "ruff<0.10", "stopit>=1.1.2,<2", - "tox>=3,<5", "pytz", "zc.customdoctests>=1.0.1,<2", "zope.testing>=4,<6", diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 1ea931fa..00000000 --- a/tox.ini +++ /dev/null @@ -1,14 +0,0 @@ -[tox] -envlist = py{py3,35,36,37,38,39}-sa_{1_0,1_1,1_2,1_3,1_4} - -[testenv] -usedevelop = True -passenv = JAVA_HOME -deps = - zope.testrunner - zope.testing - zc.customdoctests - mock - urllib3 -commands = - zope-testrunner -c --path=tests From f53cfe6071ab5052fb305e7e2409bd0843afd769 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Wed, 15 Jan 2025 23:57:17 +0100 Subject: [PATCH 19/31] Marshalling: Use `orjson` to improve JSON serialization performance https://github.com/ijl/orjson --- CHANGES.rst | 11 +++++++ setup.py | 1 + src/crate/client/http.py | 60 +++++++++++++++++++++------------------ tests/client/test_http.py | 14 ++++----- 4 files changed, 52 insertions(+), 34 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 2cf9c9dd..25ecde6f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,17 @@ Changes for crate Unreleased ========== +- Switched JSON encoder to use the `orjson`_ library, to improve JSON + marshalling performance. Thanks, @widmogrod. + orjson is fast and in some spots even more correct when compared against + Python's stdlib ``json`` module. Contrary to the stdlib variant, orjson + will serialize to ``bytes`` instead of ``str``. Please also note it + will not deserialize to dataclasses, UUIDs, decimals, etc., or support + ``object_hook``. Within ``crate-python``, it is applied with an encoder + function for additional type support about Python's ``Decimal`` type and + freezegun's ``FakeDatetime`` type. + +.. _orjson: https://github.com/ijl/orjson 2024/11/23 1.0.1 ================ diff --git a/setup.py b/setup.py index 0892ed3a..15591f88 100644 --- a/setup.py +++ b/setup.py @@ -54,6 +54,7 @@ def read(path): packages=find_namespace_packages("src"), package_dir={"": "src"}, install_requires=[ + "orjson<4", "urllib3", "verlib2", ], diff --git a/src/crate/client/http.py b/src/crate/client/http.py index e2c164d9..8d19b9c4 100644 --- a/src/crate/client/http.py +++ b/src/crate/client/http.py @@ -20,23 +20,21 @@ # software solely pursuant to the terms of the relevant commercial agreement. -import calendar import heapq import io -import json import logging import os import re import socket import ssl import threading +import typing as t from base64 import b64encode -from datetime import date, datetime, timezone from decimal import Decimal from time import time from urllib.parse import urlparse -from uuid import UUID +import orjson import urllib3 from urllib3 import connection_from_url from urllib3.connection import HTTPConnection @@ -86,25 +84,33 @@ def super_len(o): return None -class CrateJsonEncoder(json.JSONEncoder): - epoch_aware = datetime(1970, 1, 1, tzinfo=timezone.utc) - epoch_naive = datetime(1970, 1, 1) - - def default(self, o): - if isinstance(o, (Decimal, UUID)): - return str(o) - if isinstance(o, datetime): - if o.tzinfo is not None: - delta = o - self.epoch_aware - else: - delta = o - self.epoch_naive - return int( - delta.microseconds / 1000.0 - + (delta.seconds + delta.days * 24 * 3600) * 1000.0 - ) - if isinstance(o, date): - return calendar.timegm(o.timetuple()) * 1000 - return json.JSONEncoder.default(self, o) +def cratedb_json_encoder(obj: t.Any) -> str: + """ + Encoder function for orjson, with additional type support. + + - Python's `Decimal` type. + - freezegun's `FakeDatetime` type. + + https://github.com/ijl/orjson#default + """ + if isinstance(obj, Decimal): + return str(obj) + elif hasattr(obj, "isoformat"): + return obj.isoformat() + raise TypeError + + +def json_dumps(obj: t.Any) -> bytes: + """ + Serialize to JSON format, using `orjson`, with additional type support. + + https://github.com/ijl/orjson + """ + return orjson.dumps( + obj, + default=cratedb_json_encoder, + option=(orjson.OPT_NON_STR_KEYS | orjson.OPT_SERIALIZE_NUMPY), + ) class Server: @@ -180,7 +186,7 @@ def close(self): def _json_from_response(response): try: - return json.loads(response.data.decode("utf-8")) + return orjson.loads(response.data) except ValueError as ex: raise ProgrammingError( "Invalid server response of content-type '{}':\n{}".format( @@ -223,7 +229,7 @@ def _raise_for_status_real(response): if response.status == 503: raise ConnectionError(message) if response.headers.get("content-type", "").startswith("application/json"): - data = json.loads(response.data.decode("utf-8")) + data = orjson.loads(response.data) error = data.get("error", {}) error_trace = data.get("error_trace", None) if "results" in data: @@ -323,7 +329,7 @@ def _update_pool_kwargs_for_ssl_minimum_version(server, kwargs): kwargs["ssl_minimum_version"] = ssl.TLSVersion.MINIMUM_SUPPORTED -def _create_sql_payload(stmt, args, bulk_args): +def _create_sql_payload(stmt, args, bulk_args) -> bytes: if not isinstance(stmt, str): raise ValueError("stmt is not a string") if args and bulk_args: @@ -334,7 +340,7 @@ def _create_sql_payload(stmt, args, bulk_args): data["args"] = args if bulk_args: data["bulk_args"] = bulk_args - return json.dumps(data, cls=CrateJsonEncoder) + return json_dumps(data) def _get_socket_opts( diff --git a/tests/client/test_http.py b/tests/client/test_http.py index 610197a8..554fbe5f 100644 --- a/tests/client/test_http.py +++ b/tests/client/test_http.py @@ -49,9 +49,9 @@ ) from crate.client.http import ( Client, - CrateJsonEncoder, _get_socket_opts, _remove_certs_for_non_https, + json_dumps, ) REQUEST = "crate.client.http.Server.request" @@ -318,7 +318,7 @@ def test_datetime_is_converted_to_ts(self, request): # convert string to dict # because the order of the keys isn't deterministic data = json.loads(request.call_args[1]["data"]) - self.assertEqual(data["args"], [1425108700000]) + self.assertEqual(data["args"], ["2015-02-28T07:31:40"]) client.close() @patch(REQUEST, autospec=True) @@ -329,7 +329,7 @@ def test_date_is_converted_to_ts(self, request): day = dt.date(2016, 4, 21) client.sql("insert into users (dt) values (?)", (day,)) data = json.loads(request.call_args[1]["data"]) - self.assertEqual(data["args"], [1461196800000]) + self.assertEqual(data["args"], ["2016-04-21"]) client.close() def test_socket_options_contain_keepalive(self): @@ -724,10 +724,10 @@ def test_username(self): class TestCrateJsonEncoder(TestCase): def test_naive_datetime(self): data = dt.datetime.fromisoformat("2023-06-26T09:24:00.123") - result = json.dumps(data, cls=CrateJsonEncoder) - self.assertEqual(result, "1687771440123") + result = json_dumps(data) + self.assertEqual(result, b'"2023-06-26T09:24:00.123000"') def test_aware_datetime(self): data = dt.datetime.fromisoformat("2023-06-26T09:24:00.123+02:00") - result = json.dumps(data, cls=CrateJsonEncoder) - self.assertEqual(result, "1687764240123") + result = json_dumps(data) + self.assertEqual(result, b'"2023-06-26T09:24:00.123000+02:00"') From 44cad01a26df16a5bccbbb7e5863b24f116d7293 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Fri, 17 Jan 2025 20:29:00 +0100 Subject: [PATCH 20/31] Marshalling: Restore CrateDB standard encoder --- CHANGES.rst | 16 +++++++++++----- src/crate/client/http.py | 36 +++++++++++++++++++++++++++++------- tests/client/test_http.py | 8 ++++---- 3 files changed, 44 insertions(+), 16 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 25ecde6f..50da0e85 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -7,15 +7,21 @@ Unreleased - Switched JSON encoder to use the `orjson`_ library, to improve JSON marshalling performance. Thanks, @widmogrod. + orjson is fast and in some spots even more correct when compared against Python's stdlib ``json`` module. Contrary to the stdlib variant, orjson - will serialize to ``bytes`` instead of ``str``. Please also note it - will not deserialize to dataclasses, UUIDs, decimals, etc., or support - ``object_hook``. Within ``crate-python``, it is applied with an encoder - function for additional type support about Python's ``Decimal`` type and - freezegun's ``FakeDatetime`` type. + will serialize to ``bytes`` instead of ``str``. When sending data to CrateDB, + ``crate-python`` uses a custom encoder to add support for additional data + types. + + - Python's ``Decimal`` type will be serialized to ``str``. + - Python's ``dt.datetime`` and ``dt.date`` types will be serialized to + ``int`` (``LONG``) after converting to milliseconds since epoch, to + optimally accommodate CrateDB's `TIMESTAMP`_ representation. + - NumPy's data types will be handled by ``orjson`` without any ado. .. _orjson: https://github.com/ijl/orjson +.. _TIMESTAMP: https://cratedb.com/docs/crate/reference/en/latest/general/ddl/data-types.html#type-timestamp 2024/11/23 1.0.1 ================ diff --git a/src/crate/client/http.py b/src/crate/client/http.py index 8d19b9c4..a1251d34 100644 --- a/src/crate/client/http.py +++ b/src/crate/client/http.py @@ -20,6 +20,8 @@ # software solely pursuant to the terms of the relevant commercial agreement. +import calendar +import datetime as dt import heapq import io import logging @@ -84,19 +86,35 @@ def super_len(o): return None -def cratedb_json_encoder(obj: t.Any) -> str: +epoch_aware = dt.datetime(1970, 1, 1, tzinfo=dt.timezone.utc) +epoch_naive = dt.datetime(1970, 1, 1) + + +def json_encoder(obj: t.Any) -> t.Union[int, str]: """ Encoder function for orjson, with additional type support. - - Python's `Decimal` type. - - freezegun's `FakeDatetime` type. + - Python's `Decimal` type will be serialized to `str`. + - Python's `dt.datetime` and `dt.date` types will be + serialized to `int` after converting to milliseconds + since epoch. https://github.com/ijl/orjson#default + https://cratedb.com/docs/crate/reference/en/latest/general/ddl/data-types.html#type-timestamp """ if isinstance(obj, Decimal): return str(obj) - elif hasattr(obj, "isoformat"): - return obj.isoformat() + if isinstance(obj, dt.datetime): + if obj.tzinfo is not None: + delta = obj - epoch_aware + else: + delta = obj - epoch_naive + return int( + delta.microseconds / 1000.0 + + (delta.seconds + delta.days * 24 * 3600) * 1000.0 + ) + if isinstance(obj, dt.date): + return calendar.timegm(obj.timetuple()) * 1000 raise TypeError @@ -108,8 +126,12 @@ def json_dumps(obj: t.Any) -> bytes: """ return orjson.dumps( obj, - default=cratedb_json_encoder, - option=(orjson.OPT_NON_STR_KEYS | orjson.OPT_SERIALIZE_NUMPY), + default=json_encoder, + option=( + orjson.OPT_PASSTHROUGH_DATETIME + | orjson.OPT_NON_STR_KEYS + | orjson.OPT_SERIALIZE_NUMPY + ), ) diff --git a/tests/client/test_http.py b/tests/client/test_http.py index 554fbe5f..c4c0609e 100644 --- a/tests/client/test_http.py +++ b/tests/client/test_http.py @@ -318,7 +318,7 @@ def test_datetime_is_converted_to_ts(self, request): # convert string to dict # because the order of the keys isn't deterministic data = json.loads(request.call_args[1]["data"]) - self.assertEqual(data["args"], ["2015-02-28T07:31:40"]) + self.assertEqual(data["args"], [1425108700000]) client.close() @patch(REQUEST, autospec=True) @@ -329,7 +329,7 @@ def test_date_is_converted_to_ts(self, request): day = dt.date(2016, 4, 21) client.sql("insert into users (dt) values (?)", (day,)) data = json.loads(request.call_args[1]["data"]) - self.assertEqual(data["args"], ["2016-04-21"]) + self.assertEqual(data["args"], [1461196800000]) client.close() def test_socket_options_contain_keepalive(self): @@ -725,9 +725,9 @@ class TestCrateJsonEncoder(TestCase): def test_naive_datetime(self): data = dt.datetime.fromisoformat("2023-06-26T09:24:00.123") result = json_dumps(data) - self.assertEqual(result, b'"2023-06-26T09:24:00.123000"') + self.assertEqual(result, b"1687771440123") def test_aware_datetime(self): data = dt.datetime.fromisoformat("2023-06-26T09:24:00.123+02:00") result = json_dumps(data) - self.assertEqual(result, b'"2023-06-26T09:24:00.123000+02:00"') + self.assertEqual(result, b"1687764240123") From 6ec9995f3ede0f392c24ef712d7d2dadd8d99093 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Thu, 30 Jan 2025 23:42:48 +0100 Subject: [PATCH 21/31] Release 2.0.0 --- CHANGES.rst | 3 +++ src/crate/client/__init__.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 50da0e85..e9e73d94 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,9 @@ Changes for crate Unreleased ========== +2025/01/30 2.0.0 +================ + - Switched JSON encoder to use the `orjson`_ library, to improve JSON marshalling performance. Thanks, @widmogrod. diff --git a/src/crate/client/__init__.py b/src/crate/client/__init__.py index 2fec7abd..ac58fb77 100644 --- a/src/crate/client/__init__.py +++ b/src/crate/client/__init__.py @@ -29,7 +29,7 @@ # version string read from setup.py using a regex. Take care not to break the # regex! -__version__ = "1.0.1" +__version__ = "2.0.0" # codeql[py/unused-global-variable] apilevel = "2.0" From c63f75c6b2e11651dc36212bfa476d352e18d0ee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 14:28:39 +0000 Subject: [PATCH 22/31] Chore(deps-dev): Update mypy requirement from <1.15 to <1.16 Updates the requirements on [mypy](https://github.com/python/mypy) to permit the latest version. - [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md) - [Commits](https://github.com/python/mypy/compare/v0.1.0...v1.15.0) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 15591f88..12737e3d 100644 --- a/setup.py +++ b/setup.py @@ -67,7 +67,7 @@ def read(path): 'backports.zoneinfo<1; python_version<"3.9"', "certifi", "createcoverage>=1,<2", - "mypy<1.15", + "mypy<1.16", "poethepoet<0.33", "ruff<0.10", "stopit>=1.1.2,<2", From 81a50449ff3d7396684ba504f3e20935c7896c3d Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Tue, 18 Feb 2025 23:28:52 +0100 Subject: [PATCH 23/31] CI: Improve setup of and caching with uv --- .github/workflows/codeql.yml | 13 +++++++------ .github/workflows/nightly.yml | 11 +++++++---- .github/workflows/release.yml | 17 ++++++++++++----- .github/workflows/tests.yml | 11 +++++++---- 4 files changed, 33 insertions(+), 19 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 6d0f4436..29c9ae92 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -30,6 +30,7 @@ jobs: fail-fast: false matrix: language: [ python ] + python-version: ['3.11'] steps: - name: Checkout @@ -38,15 +39,15 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: 3.11 - architecture: x64 - cache: 'pip' - cache-dependency-path: | - setup.py + python-version: ${{ matrix.python-version }} - - name: Install uv + - name: Set up uv uses: astral-sh/setup-uv@v5 with: + cache-dependency-glob: | + setup.py + cache-suffix: ${{ matrix.python-version }} + enable-cache: true version: "latest" - name: Initialize CodeQL diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index cd5fa37f..964de178 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -25,16 +25,19 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} + + - name: Set up Python uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - cache: 'pip' - cache-dependency-path: 'setup.py' - - name: Install uv + - name: Set up uv uses: astral-sh/setup-uv@v5 with: + cache-dependency-glob: | + setup.py + cache-suffix: ${{ matrix.python-version }} + enable-cache: true version: "latest" - name: Invoke tests diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index eca585dc..b1f221b8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,12 @@ on: push jobs: pypi: name: Build & publish package to pypi - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: ['ubuntu-latest'] + python-version: ['3.11'] if: startsWith(github.event.ref, 'refs/tags') steps: - uses: actions/checkout@v4 @@ -14,13 +19,15 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' - cache: 'pip' - cache-dependency-path: 'setup.py' + python-version: ${{ matrix.python-version }} - - name: Install uv + - name: Set up uv uses: astral-sh/setup-uv@v5 with: + cache-dependency-glob: | + setup.py + cache-suffix: ${{ matrix.python-version }} + enable-cache: true version: "latest" - name: Build package diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 16ed304a..fe34eff0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -40,16 +40,19 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} + + - name: Set up Python uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - cache: 'pip' - cache-dependency-path: setup.py - - name: Install uv + - name: Set up uv uses: astral-sh/setup-uv@v5 with: + cache-dependency-glob: | + setup.py + cache-suffix: ${{ matrix.python-version }} + enable-cache: true version: "latest" - name: Invoke tests From 2d325376d370e08f80f2749f4bc784f41cbdef69 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 18 Feb 2025 22:47:39 +0000 Subject: [PATCH 24/31] Chore(deps-dev): Update zope-testrunner requirement Updates the requirements on [zope-testrunner](https://github.com/zopefoundation/zope.testrunner) to permit the latest version. - [Changelog](https://github.com/zopefoundation/zope.testrunner/blob/master/CHANGES.rst) - [Commits](https://github.com/zopefoundation/zope.testrunner/compare/5.0...7.0) --- updated-dependencies: - dependency-name: zope-testrunner dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 12737e3d..5a7445c8 100644 --- a/setup.py +++ b/setup.py @@ -74,7 +74,7 @@ def read(path): "pytz", "zc.customdoctests>=1.0.1,<2", "zope.testing>=4,<6", - "zope.testrunner>=5,<7", + "zope.testrunner>=5,<8", ], }, python_requires=">=3.6", From 819b63e512574abb707a8f10716298381bcd9fef Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Thu, 6 Mar 2025 23:08:05 +0100 Subject: [PATCH 25/31] Chore: Relax dependency on poethepoet --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 5a7445c8..408d283a 100644 --- a/setup.py +++ b/setup.py @@ -68,7 +68,7 @@ def read(path): "certifi", "createcoverage>=1,<2", "mypy<1.16", - "poethepoet<0.33", + "poethepoet<1", "ruff<0.10", "stopit>=1.1.2,<2", "pytz", From 3f133eb8a3bee5b4697ba5bbd708e88bc68a4567 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Mar 2025 14:54:09 +0000 Subject: [PATCH 26/31] Chore(deps-dev): Update ruff requirement from <0.10 to <0.12 Updates the requirements on [ruff](https://github.com/astral-sh/ruff) to permit the latest version. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/v0.0.18...0.11.0) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 408d283a..386b3c35 100644 --- a/setup.py +++ b/setup.py @@ -69,7 +69,7 @@ def read(path): "createcoverage>=1,<2", "mypy<1.16", "poethepoet<1", - "ruff<0.10", + "ruff<0.12", "stopit>=1.1.2,<2", "pytz", "zc.customdoctests>=1.0.1,<2", From 5ab391c2cae8d006858c0cde8964106c7d885e06 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Fri, 28 Mar 2025 16:16:33 +0100 Subject: [PATCH 27/31] Documentation: Remove page about SQLAlchemy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The location redirects to [1] anyway. [1] https://cratedb.com/docs/sqlalchemy-cratedb/ --- docs/connect.rst | 2 +- docs/index-all.rst | 1 - docs/index.rst | 2 +- docs/query.rst | 2 +- docs/sqlalchemy.rst | 17 ----------------- 5 files changed, 3 insertions(+), 21 deletions(-) delete mode 100644 docs/sqlalchemy.rst diff --git a/docs/connect.rst b/docs/connect.rst index 944fe263..774f6746 100644 --- a/docs/connect.rst +++ b/docs/connect.rst @@ -10,7 +10,7 @@ Connect to CrateDB `Python Database API Specification v2.0`_ (PEP 249). For help using the `SQLAlchemy`_ dialect, consult the - :ref:`SQLAlchemy dialect documentation `. + :ref:`SQLAlchemy dialect documentation `. .. SEEALSO:: diff --git a/docs/index-all.rst b/docs/index-all.rst index 85a508e9..5d9244d5 100644 --- a/docs/index-all.rst +++ b/docs/index-all.rst @@ -16,7 +16,6 @@ CrateDB Python Client -- all pages connect query blobs - sqlalchemy data-types by-example/index other-options diff --git a/docs/index.rst b/docs/index.rst index 67415c94..353f8c69 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -99,7 +99,7 @@ please consult the :ref:`data-types` documentation page. Migration Notes =============== -The :ref:`CrateDB dialect ` for `SQLAlchemy`_ is provided +The :ref:`CrateDB dialect ` for `SQLAlchemy`_ is provided by the `sqlalchemy-cratedb`_ package. If you are migrating from previous versions of ``crate[sqlalchemy]<1.0.0``, you diff --git a/docs/query.rst b/docs/query.rst index 00da8170..eb948fc0 100644 --- a/docs/query.rst +++ b/docs/query.rst @@ -10,7 +10,7 @@ Query CrateDB `Python Database API Specification v2.0`_ (PEP 249). For help using the `SQLAlchemy`_ dialect, consult - :ref:`the SQLAlchemy dialect documentation `. + :ref:`the SQLAlchemy dialect documentation `. .. SEEALSO:: diff --git a/docs/sqlalchemy.rst b/docs/sqlalchemy.rst deleted file mode 100644 index caf5ca8d..00000000 --- a/docs/sqlalchemy.rst +++ /dev/null @@ -1,17 +0,0 @@ -.. _sqlalchemy-support: -.. _using-sqlalchemy: - -================== -SQLAlchemy support -================== - -`SQLAlchemy`_ is the most popular `Object-Relational Mapping`_ (ORM) library -for Python. - -The `SQLAlchemy`_ CrateDB dialect is provided by the `sqlalchemy-cratedb`_ -package. - - -.. _Object-Relational Mapping: https://en.wikipedia.org/wiki/Object-relational_mapping -.. _SQLAlchemy: https://www.sqlalchemy.org/ -.. _sqlalchemy-cratedb: https://github.com/crate-workbench/sqlalchemy-cratedb From 4e678baafbedda1e1ccbbcd4d1eb00c4d2c27537 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Wed, 7 May 2025 00:10:22 +0200 Subject: [PATCH 28/31] Chore: Fix build wrt. `setuptools` --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index f8de725a..cf2e5195 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ +setuptools<80.3 zc.buildout==3.3 zope.interface==6.4.post2 From d32b74a55a5fa9b7b02f039791bca668defaf0ad Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Wed, 7 May 2025 00:17:16 +0200 Subject: [PATCH 29/31] Chore: Fix build wrt. `urllib3` --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index cf2e5195..8935d351 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ setuptools<80.3 +urllib3<2.4 zc.buildout==3.3 zope.interface==6.4.post2 From fb045ec0b27c267ffd231bfc5810539bd4f7bd45 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 May 2025 22:26:32 +0000 Subject: [PATCH 30/31] Chore(deps): Bump astral-sh/setup-uv from 5 to 6 Bumps [astral-sh/setup-uv](https://github.com/astral-sh/setup-uv) from 5 to 6. - [Release notes](https://github.com/astral-sh/setup-uv/releases) - [Commits](https://github.com/astral-sh/setup-uv/compare/v5...v6) --- updated-dependencies: - dependency-name: astral-sh/setup-uv dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql.yml | 2 +- .github/workflows/nightly.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/tests.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 29c9ae92..6b2d939d 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -42,7 +42,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Set up uv - uses: astral-sh/setup-uv@v5 + uses: astral-sh/setup-uv@v6 with: cache-dependency-glob: | setup.py diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 964de178..95025896 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -32,7 +32,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Set up uv - uses: astral-sh/setup-uv@v5 + uses: astral-sh/setup-uv@v6 with: cache-dependency-glob: | setup.py diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b1f221b8..eb561b91 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,7 +22,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Set up uv - uses: astral-sh/setup-uv@v5 + uses: astral-sh/setup-uv@v6 with: cache-dependency-glob: | setup.py diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fe34eff0..47cd7414 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -47,7 +47,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Set up uv - uses: astral-sh/setup-uv@v5 + uses: astral-sh/setup-uv@v6 with: cache-dependency-glob: | setup.py From 5a9f5184a4085fd6948191f6ae3ce0d3af476736 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Fri, 9 May 2025 13:50:32 +0200 Subject: [PATCH 31/31] CI: Use Python 3.13 for CodeQL analysis --- .github/workflows/codeql.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 6b2d939d..f57f0277 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -30,7 +30,7 @@ jobs: fail-fast: false matrix: language: [ python ] - python-version: ['3.11'] + python-version: ['3.13'] steps: - name: Checkout