From 6499cca6b8f21fb2c9860b27b79a50e2d3cfa512 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sat, 7 Oct 2023 01:29:20 -0400 Subject: [PATCH 1/8] BLD: Bump version for next release --- cycler/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cycler/__init__.py b/cycler/__init__.py index 9794954..94b5f71 100644 --- a/cycler/__init__.py +++ b/cycler/__init__.py @@ -51,7 +51,8 @@ # Dict, List, Union required for runtime cast calls from typing import TypeVar, Generic, Callable, Union, Dict, List, Any, overload, cast -__version__ = "0.12.1" + +__version__ = "0.13.0.dev0" K = TypeVar("K", bound=Hashable) L = TypeVar("L", bound=Hashable) From 555b8bd47a8a64cd7dfb9f2bffd2d39792ce70f3 Mon Sep 17 00:00:00 2001 From: Jakub Wlodek Date: Fri, 26 Jul 2024 15:49:13 -0400 Subject: [PATCH 2/8] [MNT] Update error message printed on overlapping cycles to be more verbose --- cycler/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cycler/__init__.py b/cycler/__init__.py index 94b5f71..ad40377 100644 --- a/cycler/__init__.py +++ b/cycler/__init__.py @@ -82,7 +82,8 @@ def _process_keys( l_key: set[K] = set(l_peek.keys()) r_key: set[K] = set(r_peek.keys()) if l_key & r_key: - raise ValueError("Can not compose overlapping cycles") + raise ValueError(f"Cannot compose overlapping cycles, duplicate key(s): {l_key & r_key}") + return l_key | r_key From da2514cc17c49c790e018e540e19a5601e1847dd Mon Sep 17 00:00:00 2001 From: Jakub Wlodek Date: Tue, 30 Jul 2024 09:34:51 -0400 Subject: [PATCH 3/8] Utilize walrus operator --- cycler/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cycler/__init__.py b/cycler/__init__.py index ad40377..02f50c7 100644 --- a/cycler/__init__.py +++ b/cycler/__init__.py @@ -81,8 +81,8 @@ def _process_keys( r_peek: dict[K, V] = next(iter(right)) if right is not None else {} l_key: set[K] = set(l_peek.keys()) r_key: set[K] = set(r_peek.keys()) - if l_key & r_key: - raise ValueError(f"Cannot compose overlapping cycles, duplicate key(s): {l_key & r_key}") + if common_keys := l_key & r_key: + raise ValueError(f"Cannot compose overlapping cycles, duplicate key(s): {common_keys}") return l_key | r_key From 2a858e4cb711322cc06c16043ad6146d07d2e64b Mon Sep 17 00:00:00 2001 From: Jakub Wlodek Date: Fri, 2 Aug 2024 13:25:45 -0400 Subject: [PATCH 4/8] Fix linting error --- cycler/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cycler/__init__.py b/cycler/__init__.py index 02f50c7..1f05670 100644 --- a/cycler/__init__.py +++ b/cycler/__init__.py @@ -82,7 +82,9 @@ def _process_keys( l_key: set[K] = set(l_peek.keys()) r_key: set[K] = set(r_peek.keys()) if common_keys := l_key & r_key: - raise ValueError(f"Cannot compose overlapping cycles, duplicate key(s): {common_keys}") + raise ValueError( + f"Cannot compose overlapping cycles, duplicate key(s): {common_keys}" + ) return l_key | r_key From ee4fc113bfc2ec5a70ef449a3ef8e672b80c9746 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Tue, 10 Dec 2024 23:13:15 -0500 Subject: [PATCH 5/8] CI: update upload-artifact, download-artifact, gh-action-pypi-publish --- .github/workflows/release.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 88954a9..f8b4f83 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,7 +30,7 @@ jobs: run: python -m build - name: Save built packages as artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: name: packages-${{ runner.os }}-${{ steps.setup.outputs.python-version }} path: dist/ @@ -46,12 +46,14 @@ jobs: id-token: write steps: - name: Download packages - uses: actions/download-artifact@v3 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 + with: + pattern: packages-* + path: dist + merge-multiple: true - - name: Consolidate packages for upload - run: | - mkdir dist - cp packages-*/* dist/ + - name: Print out packages + run: ls dist - name: Publish package distributions to PyPI - uses: pypa/gh-action-pypi-publish@b7f401de30cb6434a1e19f805ff006643653240e # v1.8.10 + uses: pypa/gh-action-pypi-publish@15c56dba361d8335944d31a2ecd17d700fc7bcbc # v1.12.2 From 2bfda1cfdead91e79deea2644edea41f5ea3d461 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Tue, 10 Dec 2024 23:14:21 -0500 Subject: [PATCH 6/8] CI: add attestation --- .github/workflows/release.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f8b4f83..293337a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -55,5 +55,10 @@ jobs: - name: Print out packages run: ls dist + - name: Generate artifact attestation for sdist and wheel + uses: actions/attest-build-provenance@ef244123eb79f2f7a7e75d99086184180e6d0018 # v1.4.4 + with: + subject-path: dist/cycler-* + - name: Publish package distributions to PyPI uses: pypa/gh-action-pypi-publish@15c56dba361d8335944d31a2ecd17d700fc7bcbc # v1.12.2 From 6e74aa9ddb7e3c4237ba7af7814afd706a2e7050 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Mon, 16 Dec 2024 13:16:18 -0500 Subject: [PATCH 7/8] CI: update again --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 293337a..024c8d9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -56,9 +56,9 @@ jobs: run: ls dist - name: Generate artifact attestation for sdist and wheel - uses: actions/attest-build-provenance@ef244123eb79f2f7a7e75d99086184180e6d0018 # v1.4.4 + uses: actions/attest-build-provenance@7668571508540a607bdfd90a87a560489fe372eb # v2.1.0 with: subject-path: dist/cycler-* - name: Publish package distributions to PyPI - uses: pypa/gh-action-pypi-publish@15c56dba361d8335944d31a2ecd17d700fc7bcbc # v1.12.2 + uses: pypa/gh-action-pypi-publish@67339c736fd9354cd4f8cb0b744f2b82a74b5c70 # v1.12.3 From 4638537c23681aaab31b989393afa20192d5da98 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Thu, 27 Feb 2025 11:26:54 -0500 Subject: [PATCH 8/8] FIX: check that lengths match with in-place addition --- cycler/__init__.py | 4 ++++ test_cycler.py | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/cycler/__init__.py b/cycler/__init__.py index 1f05670..db476b8 100644 --- a/cycler/__init__.py +++ b/cycler/__init__.py @@ -355,6 +355,10 @@ def __iadd__(self, other: Cycler[K, V]) -> Cycler[K, V]: # type: ignore[misc] """ if not isinstance(other, Cycler): raise TypeError("Cannot += with a non-Cycler object") + if len(self) != len(other): + raise ValueError( + f"Can only add equal length cycles, not {len(self)} and {len(other)}" + ) # True shallow copy of self is fine since this is in-place old_self = copy.copy(self) self._keys = _process_keys(old_self, other) diff --git a/test_cycler.py b/test_cycler.py index 637521b..1eccac3 100644 --- a/test_cycler.py +++ b/test_cycler.py @@ -65,12 +65,22 @@ def test_prod(): _cycler_helper(c3 * c1, 45, ['lw', 'c'], target) -def test_inplace(): +def test_inplace_add(): c1 = cycler(c='rgb') c2 = cycler(lw=range(3)) c2 += c1 _cycler_helper(c2, 3, ['c', 'lw'], [list('rgb'), range(3)]) + +def test_inplace_add_len_mismatch(): + # miss-matched add lengths + c1 = cycler(c='rgb') + c3 = cycler(lw=range(15)) + with pytest.raises(ValueError): + c1 += c3 + + +def test_inplace_mul(): c3 = cycler(c='rgb') c4 = cycler(lw=range(3)) c3 *= c4