Type stubs for toolz
Project description
toolz-stubs
Type stubs for toolz and tlz - Python functional programming libraries.
Installation
pip install toolz-stubs
This installs type stubs for both toolz and tlz.
Usage
Once installed, type checkers like mypy, pyright, or basedpyright will automatically use these stubs:
import toolz
bills = {"Alice": [20, 15, 30], "Bob": [10, 35]}
totals = toolz.valmap(sum, bills) # dict[str, int]
even_entries = toolz.keyfilter(lambda k: k % 2 == 0, {1: "a", 2: "b", 3: "c"}) # dict[int, str]
names = ["Alice", "Bob", "Charlie", "Anna"]
grouped = toolz.groupby(lambda s: s[0], names) # dict[str, list[str]]
Using with cytoolz
When you pip install toolz, you also get a second package called tlz. It's a thin auto-selecting wrapper: if cytoolz (the C-accelerated version) is installed, tlz imports from it; otherwise it falls back to pure-Python toolz. The API is identical either way.
If you use cytoolz, you can switch your imports to tlz to get the same performance with type checking support and a graceful fallback:
# before
from cytoolz.dicttoolz import merge, valmap
from cytoolz.functoolz import curry, compose, pipe
# after — same performance, now with type stubs
from tlz.dicttoolz import merge, valmap
from tlz.functoolz import curry, compose, pipe
What's Included
This package provides type stubs (.pyi files) for:
- toolz: The pure Python functional programming library
- tlz: The auto-selecting wrapper (uses cytoolz if installed, otherwise falls back to toolz)
Modules covered:
toolz.functoolz/tlz.functoolz- Function manipulation (curry, compose, pipe, etc.)toolz.itertoolz/tlz.itertoolz- Iterator utilities (groupby, partition, sliding_window, etc.)toolz.dicttoolz/tlz.dicttoolz- Dictionary operations (merge, valmap, keyfilter, etc.)toolz.curried/tlz.curried- Pre-curried versions of all functionstoolz.recipes/tlz.recipes- Common recipes (countby, partitionby)toolz.sandbox/tlz.sandbox- Experimental utilities
Development
make sync # Install dependencies
make check # Run type checker
make test # Run tests
make lint # Run linter
make format # Check formatting
make build # Build wheel
If manually running commands, be sure to specify --no-editable or hatchling will mispackage toolz & tlz packages.
Tests
The tests in tests/ serve a few purposes:
- they verify runtime behavior with pytest.
- they verify that these stubs genuinely improve the developer experience in an IDE.
- they are type-checked by basedpyright. This ensures the stubs match actual library behavior.
Contributing
Contributions are welcome! Areas that could use improvement:
- More precise generic types
- Additional overloads for functions with variable signatures
- Improved curry and composition typing
- Protocol types for duck-typed parameters
License
BSD 3-Clause (same as toolz)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file toolz_stubs-0.4.1.tar.gz.
File metadata
- Download URL: toolz_stubs-0.4.1.tar.gz
- Upload date:
- Size: 65.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6fc55936adb699f03934ad4789f62b823e3e41fbd1673b8dd5e950be3b3107e
|
|
| MD5 |
4f2a90fe0fb2780e2ad7734f4df8aa9f
|
|
| BLAKE2b-256 |
50b884bdb65e9a88ff978f99dcff09e3f33aa20eeedcec2a6705b7744b4de524
|
Provenance
The following attestation bundles were made for toolz_stubs-0.4.1.tar.gz:
Publisher:
publish.yml on mgrinshpon/toolz-stubs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
toolz_stubs-0.4.1.tar.gz -
Subject digest:
e6fc55936adb699f03934ad4789f62b823e3e41fbd1673b8dd5e950be3b3107e - Sigstore transparency entry: 1255780713
- Sigstore integration time:
-
Permalink:
mgrinshpon/toolz-stubs@e14f5913b5de8cc136eb1d800dff31263a119069 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/mgrinshpon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e14f5913b5de8cc136eb1d800dff31263a119069 -
Trigger Event:
release
-
Statement type:
File details
Details for the file toolz_stubs-0.4.1-py3-none-any.whl.
File metadata
- Download URL: toolz_stubs-0.4.1-py3-none-any.whl
- Upload date:
- Size: 68.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c86f61616ea2a0a369641f0b2665d09d03cb0da18afa79703c2c2e27da898a7
|
|
| MD5 |
7d58e4aeb4f72ded267309dd9fc5f510
|
|
| BLAKE2b-256 |
54f3aa2303b515b881699ce38ac4bf4573857187f06b49420b17792aa8784bbf
|
Provenance
The following attestation bundles were made for toolz_stubs-0.4.1-py3-none-any.whl:
Publisher:
publish.yml on mgrinshpon/toolz-stubs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
toolz_stubs-0.4.1-py3-none-any.whl -
Subject digest:
4c86f61616ea2a0a369641f0b2665d09d03cb0da18afa79703c2c2e27da898a7 - Sigstore transparency entry: 1255780828
- Sigstore integration time:
-
Permalink:
mgrinshpon/toolz-stubs@e14f5913b5de8cc136eb1d800dff31263a119069 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/mgrinshpon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e14f5913b5de8cc136eb1d800dff31263a119069 -
Trigger Event:
release
-
Statement type: