Skip to main content

An extensive utility library for python, focusing especially on iterables and a Regex 'Store'.

Project description

logo

myBasis: Ergonomic Python Utilities

Status: Pre-launch — under active development. APIs may change before 1.0.

Pipeline Status Test Coverage License

pre-commit pyrefly ruff

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:

  1. Let me know!

  2. 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

my_basis-0.8.2.tar.gz (218.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

my_basis-0.8.2-py3-none-any.whl (255.3 kB view details)

Uploaded Python 3

File details

Details for the file my_basis-0.8.2.tar.gz.

File metadata

  • Download URL: my_basis-0.8.2.tar.gz
  • Upload date:
  • Size: 218.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for my_basis-0.8.2.tar.gz
Algorithm Hash digest
SHA256 50646474ccb61dca0e8e9e29b5326a9dedb1857cbb6089d7faf8d608829cd86a
MD5 9bd06b756a2ff75a4b39803a8d80c576
BLAKE2b-256 0f7785ff6329cd88b2a0f11c5fa11767ccbc63fee4479a62153b599c2fc758b3

See more details on using hashes here.

File details

Details for the file my_basis-0.8.2-py3-none-any.whl.

File metadata

  • Download URL: my_basis-0.8.2-py3-none-any.whl
  • Upload date:
  • Size: 255.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for my_basis-0.8.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ccc50b0c41a663183204bc5925d3708b4d1975e8a20f1714fc209a8f6861244e
MD5 a654c6bda3d0db7d0c7bf99d39cbfff2
BLAKE2b-256 89a7f9d58cfbe8e940a7a42f437e8f564f802d28592c87051cd696c0a1341f83

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page