An extensive utility library for python, focusing especially on iterables and a Regex 'Store'.
Project description
myBasis: Ergonomic Python Utilities
Status: Pre-launch — under active development. APIs may change before 1.0.
The myBasis Python package contains a variety of utilities generally centered around the
topics of text processing, functional programming, and runtime type coercion.
This broad scope is somewhat unusual, as any given application will likely only need a small
subset of the contents; for this reason, it is intended for use in applications where
dependency purity isn't very important, such as personal projects, local development scripts,
offline data-processing projects, and prototypes.
As a metric, the package imports 32 dependencies totalling around ~250 MB in uncompressed
.venv/lib/ files.
Install
my-basis is not yet published to PyPI. Every consumer in this ecosystem depends on it the
same way: as an editable local path added via uv.
# pyproject.toml
dependencies = [
"my-basis",
# ...
]
[tool.uv.sources]
my-basis = { path = "../libs/basis", editable = true }
Adjust the relative path to wherever this repo lives on disk from the consuming project,
then run uv sync.
Quickstart
The core loop: cast untyped data into a target type, check whether a value already fits one,
and introspect a type itself as a MyType node.
from my import ty, MyType
# Cast: coerce arbitrary data into a target type, best-effort.
ty.cast('42', int) # -> 42
ty.cast('a,b,c', list[str]) # -> ['a', 'b', 'c']
ty.cast({'a': '1', 'b': '2'}, dict[str, int]) # -> {'a': 1, 'b': 2}
# Check: does this value already conform to a type, without coercing it?
ty.check(42, int) # -> True
ty.check('42', int) # -> False
# MyType: parse any type expression into an introspectable node.
t = MyType(dict[str, int])
t.main # -> <class 'dict'>
t.args # -> (MyType[str], MyType[int])
t.root # -> dict[str, int]
ty is the package-wide Typist singleton -- cast/check/match chambers composed onto
one object. See docs/ (built locally with task docs, or the hosted site once published)
for the full subpackage tour: typing (this cast/check/match/MyType machinery), types,
regex, caches, apis, utils, and files.
Modules
Utility Functions
Iteration Utilities
Syntax Utilities
Semantic Utilities
Text Utilities
Code Utilities
System Utilities
Logging
Profiling
Command Line Interaction
File System Validation
Enumerations
UUIDs
Environment Variables
Reusable Types
Minskian Predicates
Type Coercion
"Vibe" Typing
Text Processing
Regex "Stores"
Text Buffers
Markdown Trees
Typed Caches
File Caches
Nested Caches
Pickle Caches
Singleton Interfaces
GoogleSheets
Environment
Caveats
Pydantic-first
Although you can of course use this package without using Pydantic yourself, you'll be
missing out on a lot of the ergonomic benefits: basically every class is a Pydantic "model",
and the logging functionality included in my/base/utils.py
exclusively supports Pydantic's Logfire.
Built for Python 3.12+
It would be pretty trivial to make this library work with versions as old as 3.11, and I aim to do this when I find the time. Anything older than that would be quite the reach however, as the typing code uses 3.11 syntax throughout a relatively complex module.
If you're blocked by this, either:
-
Let me know!
-
See if you can just manually extract the code you need from the repo. If you're only using one or two modules, it may be relatively trivial to backport the syntax.
Project details
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 my_basis-0.8.3.tar.gz.
File metadata
- Download URL: my_basis-0.8.3.tar.gz
- Upload date:
- Size: 219.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d566f8168aaf69e02d8a1103c1fd62444a871bbd9d996912b8450077d9d4e9de
|
|
| MD5 |
c1a110cc83489718cf6246f95199e89a
|
|
| BLAKE2b-256 |
aa6f0e1261fb6c05c1c15cb995bd61ae824583dbd310d84456916b0ae6b27454
|
File details
Details for the file my_basis-0.8.3-py3-none-any.whl.
File metadata
- Download URL: my_basis-0.8.3-py3-none-any.whl
- Upload date:
- Size: 256.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55a68b1e968777e635d0f11296398cf2cb5992ebf73db40f94e6fcd330443be5
|
|
| MD5 |
7c9d1f3d0676d2afe65ff60715627c97
|
|
| BLAKE2b-256 |
85f081bf07d9145ad16d6a18ea53be52c66fce8c7dbe456e7869d5c3613c2a99
|