tha-utils-helper 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,22 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: ["main"]
6
+ pull_request:
7
+ branches: ["main"]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - uses: actions/setup-python@v5
18
+ with:
19
+ python-version: ${{ matrix.python-version }}
20
+ allow-prereleases: true
21
+ - run: pip install -e ".[dev]"
22
+ - run: pytest tests/
@@ -0,0 +1,38 @@
1
+ name: Publish
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ publish-testpypi:
10
+ runs-on: ubuntu-latest
11
+ environment: testpypi
12
+ permissions:
13
+ id-token: write
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - uses: actions/setup-python@v5
17
+ with:
18
+ python-version: "3.12"
19
+ - run: pip install hatchling build
20
+ - run: python -m build
21
+ - uses: pypa/gh-action-pypi-publish@release/v1
22
+ with:
23
+ repository-url: https://test.pypi.org/legacy/
24
+
25
+ publish-pypi:
26
+ needs: publish-testpypi
27
+ runs-on: ubuntu-latest
28
+ environment: pypi
29
+ permissions:
30
+ id-token: write
31
+ steps:
32
+ - uses: actions/checkout@v4
33
+ - uses: actions/setup-python@v5
34
+ with:
35
+ python-version: "3.12"
36
+ - run: pip install hatchling build
37
+ - run: python -m build
38
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,9 @@
1
+ __pycache__/
2
+ *.pyc
3
+ *.pyo
4
+ *.egg-info/
5
+ dist/
6
+ build/
7
+ .mypy_cache/
8
+ .ruff_cache/
9
+ .pytest_cache/
@@ -0,0 +1,57 @@
1
+ Metadata-Version: 2.4
2
+ Name: tha-utils-helper
3
+ Version: 0.1.0
4
+ Summary: A Tabular Helper utility library with general-purpose helpers for the tha-* ecosystem.
5
+ License: MIT
6
+ Keywords: chunks,helpers,list,utilities
7
+ Classifier: License :: OSI Approved :: MIT License
8
+ Classifier: Operating System :: OS Independent
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Typing :: Typed
11
+ Requires-Python: >=3.10
12
+ Provides-Extra: dev
13
+ Requires-Dist: mypy; extra == 'dev'
14
+ Requires-Dist: pytest; extra == 'dev'
15
+ Requires-Dist: ruff; extra == 'dev'
16
+ Description-Content-Type: text/markdown
17
+
18
+ # tha-utils-helper
19
+
20
+ [![CI](https://github.com/tha-guy-nate/tha-utils-helper/actions/workflows/ci.yml/badge.svg)](https://github.com/tha-guy-nate/tha-utils-helper/actions/workflows/ci.yml)
21
+
22
+ A small Python utility library with general-purpose helpers for the `tha-*` ecosystem. No dependencies, no classes — just functions.
23
+
24
+ ## Install
25
+
26
+ ```bash
27
+ pip install tha-utils-helper
28
+ ```
29
+
30
+ ## Quick start
31
+
32
+ ```python
33
+ from tha_utils_helper import chunk_list
34
+
35
+ chunk_list([1, 2, 3, 4, 5], 2)
36
+ # [[1, 2], [3, 4], [5]]
37
+ ```
38
+
39
+ ## API
40
+
41
+ ### `chunk_list(lst, size)`
42
+
43
+ ```python
44
+ chunk_list(lst: list[T], size: int) -> list[list[T]]
45
+ ```
46
+
47
+ Splits `lst` into consecutive chunks of `size`. The final chunk may be smaller if the list doesn't divide evenly. Raises `ValueError` if `size < 1`.
48
+
49
+ ```python
50
+ chunk_list([1, 2, 3, 4, 5], 2) # [[1, 2], [3, 4], [5]]
51
+ chunk_list([1, 2, 3], 3) # [[1, 2, 3]]
52
+ chunk_list([], 5) # []
53
+ ```
54
+
55
+ ## License
56
+
57
+ MIT
@@ -0,0 +1,40 @@
1
+ # tha-utils-helper
2
+
3
+ [![CI](https://github.com/tha-guy-nate/tha-utils-helper/actions/workflows/ci.yml/badge.svg)](https://github.com/tha-guy-nate/tha-utils-helper/actions/workflows/ci.yml)
4
+
5
+ A small Python utility library with general-purpose helpers for the `tha-*` ecosystem. No dependencies, no classes — just functions.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pip install tha-utils-helper
11
+ ```
12
+
13
+ ## Quick start
14
+
15
+ ```python
16
+ from tha_utils_helper import chunk_list
17
+
18
+ chunk_list([1, 2, 3, 4, 5], 2)
19
+ # [[1, 2], [3, 4], [5]]
20
+ ```
21
+
22
+ ## API
23
+
24
+ ### `chunk_list(lst, size)`
25
+
26
+ ```python
27
+ chunk_list(lst: list[T], size: int) -> list[list[T]]
28
+ ```
29
+
30
+ Splits `lst` into consecutive chunks of `size`. The final chunk may be smaller if the list doesn't divide evenly. Raises `ValueError` if `size < 1`.
31
+
32
+ ```python
33
+ chunk_list([1, 2, 3, 4, 5], 2) # [[1, 2], [3, 4], [5]]
34
+ chunk_list([1, 2, 3], 3) # [[1, 2, 3]]
35
+ chunk_list([], 5) # []
36
+ ```
37
+
38
+ ## License
39
+
40
+ MIT
@@ -0,0 +1,31 @@
1
+ [project]
2
+ name = "tha-utils-helper"
3
+ version = "0.1.0"
4
+ description = "A Tabular Helper utility library with general-purpose helpers for the tha-* ecosystem."
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ license = { text = "MIT" }
8
+ keywords = ["utilities", "helpers", "list", "chunks"]
9
+ classifiers = [
10
+ "Programming Language :: Python :: 3",
11
+ "License :: OSI Approved :: MIT License",
12
+ "Operating System :: OS Independent",
13
+ "Typing :: Typed",
14
+ ]
15
+ dependencies = []
16
+
17
+ [project.optional-dependencies]
18
+ dev = ["pytest", "ruff", "mypy"]
19
+
20
+ [build-system]
21
+ requires = ["hatchling"]
22
+ build-backend = "hatchling.build"
23
+
24
+ [tool.hatch.build.targets.wheel]
25
+ packages = ["src/tha_utils_helper"]
26
+
27
+ [tool.ruff]
28
+ line-length = 100
29
+
30
+ [tool.mypy]
31
+ strict = true
@@ -0,0 +1,6 @@
1
+ """tha-utils-helper: general-purpose utility functions for the tha-* ecosystem."""
2
+
3
+ from .utils import chunk_list
4
+
5
+ __version__ = "0.1.0"
6
+ __all__ = ["chunk_list"]
@@ -0,0 +1,11 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TypeVar
4
+
5
+ T = TypeVar("T")
6
+
7
+
8
+ def chunk_list(lst: list[T], size: int) -> list[list[T]]:
9
+ if size < 1:
10
+ raise ValueError("size must be >= 1")
11
+ return [lst[i : i + size] for i in range(0, len(lst), size)]
@@ -0,0 +1,42 @@
1
+ import pytest
2
+
3
+ from tha_utils_helper import chunk_list
4
+
5
+
6
+ def test_chunk_even_split() -> None:
7
+ assert chunk_list([1, 2, 3, 4], 2) == [[1, 2], [3, 4]]
8
+
9
+
10
+ def test_chunk_uneven_split() -> None:
11
+ assert chunk_list([1, 2, 3, 4, 5], 2) == [[1, 2], [3, 4], [5]]
12
+
13
+
14
+ def test_chunk_size_larger_than_list() -> None:
15
+ assert chunk_list([1, 2], 10) == [[1, 2]]
16
+
17
+
18
+ def test_chunk_size_equals_list() -> None:
19
+ assert chunk_list([1, 2, 3], 3) == [[1, 2, 3]]
20
+
21
+
22
+ def test_chunk_size_one() -> None:
23
+ assert chunk_list([1, 2, 3], 1) == [[1], [2], [3]]
24
+
25
+
26
+ def test_chunk_empty_list() -> None:
27
+ assert chunk_list([], 5) == []
28
+
29
+
30
+ def test_chunk_size_zero_raises() -> None:
31
+ with pytest.raises(ValueError):
32
+ chunk_list([1, 2, 3], 0)
33
+
34
+
35
+ def test_chunk_size_negative_raises() -> None:
36
+ with pytest.raises(ValueError):
37
+ chunk_list([1, 2, 3], -1)
38
+
39
+
40
+ def test_chunk_preserves_types() -> None:
41
+ result = chunk_list(["a", "b", "c"], 2)
42
+ assert result == [["a", "b"], ["c"]]