Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
61e6a64
Unify all error messages & add a new option to allow the space separa…
xulbux May 7, 2026
881ae5b
Add better typing for the arg values `.get()` method
xulbux May 7, 2026
015ceb6
Follow no-single-letter-names everywhere, remove redundant format cod…
xulbux May 10, 2026
24a8621
Performance improvements for `Console.log()`, `Data.remove_duplicates…
xulbux May 12, 2026
0c5aa16
Improve the `ProgressBar` style
xulbux May 13, 2026
4e5144e
Performance improvements for `FormatCodes` class
xulbux May 13, 2026
a242f2b
Restructure `FormatCodes.to_ansi()` as it was getting too complex
xulbux May 13, 2026
e12c62d
Add a new `skip` param to `Console.get_args()` and new props to the `…
xulbux May 13, 2026
2de8e09
Added new `unknown_flags` attr to `ParsedArgs` and changed the type o…
xulbux May 14, 2026
2fc32b3
Exclude `./build` folder from linting
xulbux May 14, 2026
04b236b
No longer force the `Console.log()` title to be all uppercase
xulbux May 15, 2026
5819bb1
Use the rendered title length for tab size calculation in `Console.lo…
xulbux May 15, 2026
cc01edf
Improve inline `is not None` if-statements and start fixing `E501 lin…
xulbux May 15, 2026
ba1a724
Continue fixing `E501 line too long`
xulbux May 15, 2026
75b3802
wip: Completely rework the formatting API and mark the old one as dep…
xulbux May 15, 2026
9901b24
wip: Completely rework the formatting API and mark the old one as dep…
xulbux May 15, 2026
6508f2a
Remove `xulbux-lib fc` CLI command, use the new `FC` API inside the l…
xulbux May 16, 2026
9b650ad
`F.link(…)` bugfix
xulbux May 16, 2026
53d818b
Correct change log, add new `FC` class operations, and update the `sy…
xulbux May 20, 2026
e0587ea
Fix grammar mistake
xulbux May 28, 2026
ed75856
Merge branch 'main' of https://github.com/xulbux/python-lib-xulbux in…
xulbux Jun 10, 2026
2fd85a2
Improve `format_codes` ergonomics
xulbux Jun 15, 2026
31c247b
Mark things to remove as deprecated, but don't actually remove them yet
xulbux Jul 16, 2026
2ce3fa1
Fix failing workflows
xulbux Jul 16, 2026
93fffd2
Fix remaining linting problems, unify all comment styles & move Yapf …
xulbux Jul 16, 2026
b3359b8
Update logo
xulbux Jul 17, 2026
5ac641d
Improve README, rename all new ANSI API things
xulbux Jul 17, 2026
6c60638
Fix linting problems
xulbux Jul 17, 2026
7fd5649
Migrate the `date` module to the new operator-based ANSI styling API
xulbux Jul 19, 2026
27e4241
Start migrating `console` module to the new operator-based ANSI styli…
xulbux Jul 19, 2026
77c129c
Continue migrating `console` module to the new operator-based ANSI st…
xulbux Jul 19, 2026
5430b7b
Continue migrating `console` module to the new operator-based ANSI st…
xulbux Jul 19, 2026
ca82c19
Finish migrating `console` module to the new operator-based ANSI styl…
xulbux Jul 19, 2026
12e3af7
Small module export fix
xulbux Jul 20, 2026
789c9d4
Fix `@deprecated` decorator & add missing type hints
xulbux Jul 20, 2026
ef7efd2
Add missing type hints
xulbux Jul 20, 2026
4556e6a
Move to Python 3.12+ instead of 3.10+
xulbux Jul 20, 2026
0b1c639
Finish transform Python from Python 3.10+ to 3.12+
xulbux Jul 20, 2026
ecf247a
Switch linter/formatter to Ruff
xulbux Jul 20, 2026
212e30f
Fix code problems
xulbux Jul 20, 2026
756667b
Fix workflow
xulbux Jul 20, 2026
80e18e0
Improve linting/formatting with Ruff
xulbux Jul 21, 2026
dab0884
Various small fixes
xulbux Jul 21, 2026
de097f7
Various small fixes
xulbux Jul 21, 2026
d751d60
Mention no longer supported Python versions in change log & fix some …
xulbux Jul 21, 2026
9a21445
Small workflow fix
xulbux Jul 21, 2026
afe1dc6
Improve `console` module for new ANSI styling API
xulbux Jul 21, 2026
348f2d7
Small fix
xulbux Jul 21, 2026
a7ffabb
Correct type hints
xulbux Jul 21, 2026
81e104c
Add missing tests
xulbux Jul 21, 2026
5b81fa4
Improve `console` type hints
xulbux Jul 21, 2026
19f94f8
Update `console` docstrings
xulbux Jul 21, 2026
85389c7
Improve `console` tests
xulbux Jul 21, 2026
59b83ea
Various small code improvements
xulbux Jul 21, 2026
fe7321a
Main transformation: remove module default classes
xulbux Jul 21, 2026
1820cbb
Fix errors from transformation
xulbux Jul 21, 2026
fa284f9
Update docs
xulbux Jul 21, 2026
c09f63a
Small type fix
xulbux Jul 22, 2026
d7aa55a
Write custom stub generator & improve general lib performance
xulbux Jul 22, 2026
f1cfb3d
Fix stub gen problems
xulbux Jul 22, 2026
5887e41
Fix stub gen problems (2)
xulbux Jul 22, 2026
5f7425a
Update docs & fix a lot of tiny bugs
xulbux Jul 22, 2026
51067cf
Fix getters
xulbux Jul 22, 2026
3a9d81f
Small type mismatch fix
xulbux Jul 23, 2026
fd7425f
Stub formatting improvement
xulbux Jul 23, 2026
53e6762
Improve stub generation
xulbux Jul 23, 2026
e205adf
Naming
xulbux Jul 24, 2026
97876cf
Small improvement to `console.confirm()`
xulbux Jul 24, 2026
4d23cf3
Small `console` bugfix
xulbux Jul 24, 2026
0313681
Various small code improvements
xulbux Jul 24, 2026
091d9e2
Only strip complex default values from stubs
xulbux Jul 24, 2026
4cedf77
Code fmt
xulbux Aug 3, 2026
12648c5
Potential workflow fix
xulbux Aug 3, 2026
27cf86d
Various small code fixes and performance improvements
xulbux Aug 3, 2026
3b1363f
Improve `data.render`
xulbux Aug 3, 2026
2be3fa7
Small naming fix
xulbux Aug 7, 2026
cfe8c01
Some small styling API improvements
xulbux Aug 7, 2026
dc73db7
Allow color styles in `console` funcs
xulbux Aug 7, 2026
fb91beb
Small `ansi` and `console` module fixes/improvements
xulbux Aug 10, 2026
ce21b27
Use more modern console default colors
xulbux Aug 10, 2026
c8e7962
Update emails
xulbux Aug 12, 2026
0b8be3d
Apply MD conventions
xulbux Aug 12, 2026
e0820f0
Add documentation website (wip)
xulbux Aug 13, 2026
054fb63
Docs gen encoding fix
xulbux Aug 14, 2026
008334c
Further improve docs gen and website layout/design
xulbux Aug 14, 2026
db3df52
Docs gen fixes
xulbux Aug 14, 2026
c1b7c4a
Ensure items order in docs is same as def order in code
xulbux Aug 14, 2026
026faa4
Create custom docs code syntax theme
xulbux Aug 14, 2026
f432980
Code linting/formatting fixes
xulbux Aug 14, 2026
5979c40
Small docs theme fix
xulbux Aug 14, 2026
ff96164
Correctly display submodules in right docs sidebar
xulbux Aug 15, 2026
ae0135d
Various docs improvements
xulbux Aug 15, 2026
a921527
Improve docs gen logic
xulbux Aug 16, 2026
190e1f1
Add smooth scrolling to docs
xulbux Aug 16, 2026
a4d7ba7
Add signature links to docs
xulbux Aug 16, 2026
8b9b9b0
Code fmt
xulbux Aug 16, 2026
8e6c859
Add new attached-code special component and add missing code examples…
xulbux Aug 16, 2026
faa5acf
Various docs improvements
xulbux Aug 17, 2026
bfd991e
Various docs improvements
xulbux Aug 17, 2026
e1daedd
Various small corrections
xulbux Aug 17, 2026
255ed2d
Various improvements regarding the new styling API
xulbux Aug 17, 2026
59fac38
Update workflow versions
xulbux Aug 18, 2026
8cc8609
Add sitemap to docs
xulbux Aug 18, 2026
df643a6
Small typing fix
xulbux Aug 19, 2026
c8769d1
Add new `console.ArgumentParser`
xulbux Aug 19, 2026
e39e30d
Unify `x in {y, z, …}` statements
xulbux Aug 19, 2026
7596ae9
Add 2 new custom styling API types
xulbux Aug 19, 2026
a3e5fc0
Improve code for MyPyC performance
xulbux Aug 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .agents/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Agent Guidelines for `xulbux`

When working on this repository, any AI agent or automated assistant must adhere strictly to the following rules to maintain the codebase's integrity, performance, and correctness.

## 1. Strict Typing (MyPyC Compatibility)

This library is compiled using **MyPyC**. Therefore, **EVERYTHING** must be meticulously and strictly type-hinted. Do not ever use `Any` unless it is fundamentally impossible to type-hint otherwise. All changes must be fully statically analyzable to compile correctly.

## 2. Validation & Testing

After making any changes, you must validate them by running the full suite of formatters, linters, type checkers, and tests. Fix all problems until they are completely resolved.

**On Windows:**

CD into the project root, then run:

```powershell
ruff format .; if ($?) { ruff check . --fix }; if ($?) { pyright --pythonpath "$(py -c 'import sys; print(sys.executable)')" . }; if ($?) { mypy . }; if ($?) { pytest --basetemp .pytest_tmp }
```

**On Unix:**

CD into the project root, activate the `.venv` virtual environment, then run:

```bash
ruff format . && ruff check . --fix && pyright . && mypy . && pytest
```

## 3. Ask, Don't Assume

If you run into anything you are not sure about (ambiguous requirements, complex architectural decisions, edge cases), **ask first**. Do not make assumptions about the desired behavior.

## 4. Performance & Idioms

- **Performance First:** This library prioritizes modernity and speed. Avoid eager imports for heavy operations. Utilize lazy loading via PEP 562 (`__getattr__` in `__init__.py`) and lazy compiled regular expressions (`LazyRegex`).
- **MyPyC Optimization (CRITICAL):** Because the library is compiled to C via MyPyC, standard Python performance advice doesn't always apply. You must strictly follow these rules:
- **Generators:** NEVER pass generator expressions to functions like `any()`, `all()`, `sum()`, `max()`, `min()`, `join()`, `tuple()`, etc.
- For full iterations (`join`, `sum`, `tuple`, `max`), ALWAYS wrap them in brackets `[]` to force an optimized list comprehension.
- For short-circuiting functions (`any`, `all`, `next`), write explicit unrolled native `for`-loops with `break` or `return`.
- **Membership Testing:** Always use `set`s for `in` checks instead of lists or tuples (e.g., `if x in {"a", "b"}:` instead of `if x in ("a", "b"):`).
- **String Concatenation:** Avoid using `+=` for string concatenation inside loops; prefer `.join()` with list comprehensions.
- **Map & Filter:** Do not use the `map()` or `filter()` builtins. List comprehensions are strictly faster and type-safer in MyPyC.
- **DRY Principle (Don't Repeat Yourself):** Always strive to prevent redundant code and duplicate logic. Abstract repeated patterns into reusable helper functions or classes.
- **Internal Module Aliasing:** When importing internal modules, use the `_module` suffix pattern (e.g., `from . import data as _data_module`). This prevents naming collisions and variable shadowing, and keeps the public API completely clean of internal clutter.
- **Docstrings & Syntax:** Maintain the current comment/docstring styling (which makes use of formatting elements like `<br>`). Always use backticks (`` ` ``) instead of quotes when mentioning literals, expressions, types, or variables within comments/docstrings.

## 5. Code Structure & Readability

- **Logical Placement:** Do not mindlessly append new code (variables, constants, functions, classes, etc.) to the end of a file. Always insert new code in a logical location that groups related functionality together.
- **Spacing & Formatting:** Keep the code "spacy" and readable, matching the current formatting conventions of the repository.
- **Naming Conventions:** Single-letter variables (e.g., `x`, `c`, `r`) are strictly banned. The ONLY exceptions are `i` (and rarely `j`) for loop indices, and `n` for mathematical counts/parameters. Always use fully descriptive variable names (e.g., `ch` or `channel`, `red`, `modifier`).
- **Organization:** When introducing large data structures (like hardcoded iterables or dictionaries), keep them strictly organized and structured. Default to sorting elements alphabetically unless a specific logical order is required.
50 changes: 50 additions & 0 deletions .agents/skills/build-xulbux/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
name: build-xulbux
description: Compiles and builds the xulbux MyPyC library, and generates PYI stubs.
---

# build-xulbux

Use this skill to verify that the `xulbux` library fully compiles via MyPyC, generates the correct `.pyi` stub files, and packages/installs successfully.

## 1. Verify Stub Generation

Run the following command to only generate the `.pyi` stub files to the project root without clearing them. This allows you to inspect them and verify they are generated correctly.

**On Windows:**

CD into the project root, then run:

```powershell
py setup.py --gen-stubs
```

**On Unix:**

CD into the project root, activate the `.venv` virtual environment, then run:

```bash
python setup.py --gen-stubs
```

## 2. Full Compile and Install Test

Run the following command to force pip to completely compile the MyPyC extensions and reinstall the package from the local source directory without caching. This verifies the full build pipeline.

**On Windows:**

CD into the project root, then run:

```powershell
py -m pip install . --no-deps --no-cache-dir --force-reinstall -vv
```

**On Unix:**

CD into the project root, activate the `.venv` virtual environment, then run:

```bash
pip install . --no-deps --no-cache-dir --force-reinstall -vv
```

If any of these commands fail, inspect the verbose (`-vv`) output to debug MyPyC compilation errors or stub generation issues.
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# THIS WORKFLOW WILL BUILD WHEELS FOR ALL MAJOR PLATFORMS AND UPLOAD THEM TO PYPI
# This workflow will build wheels for all major platforms and upload them to PyPI.

# TO BUILD AND INSTALL LOCALLY FOR TESTING, RUN THE FOLLOWING COMMAND:
# To build and install locally for testing, run the following command:
# py -m pip install "/path/to/python-lib-xulbux" --no-deps --no-cache-dir --force-reinstall -vv

# TO CREATE A NEW RELEASE, TAG A COMMIT WITH THE FOLLOWING FORMAT:
# To create a new release, tag a commit with the following format:
# git tag v1.X.Y
# git push origin v1.X.Y
# IF THE TAG v1.X.Y ALREADY EXISTS, RUN THE FOLLOWING COMMANDS FIRST:

# If the tag `v1.X.Y` already exists, run the following commands first:
# git tag -d v1.X.Y
# git push origin :refs/tags/v1.X.Y

Expand All @@ -17,8 +18,8 @@ permissions:
on:
push:
tags:
- "v1.[0-9]+.[0-9]+"
workflow_dispatch: # ALLOW MANUAL TRIGGER
- 'v1.[0-9]+.[0-9]+'
workflow_dispatch: # Allow manual trigger.

jobs:
build_wheels:
Expand All @@ -29,13 +30,13 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7

- name: Build wheels
uses: pypa/cibuildwheel@v3.3.0
uses: pypa/cibuildwheel@v4.2
env:
CIBW_BUILD: cp310-* cp311-* cp312-* cp313-* cp314-*
CIBW_SKIP: "*-musllinux_*"
CIBW_BUILD: cp312-* cp313-* cp314-*
CIBW_SKIP: '*-musllinux_*'
CIBW_BUILD_FRONTEND: pip
CIBW_ENVIRONMENT: XULBUX_USE_MYPYC=1

Expand All @@ -49,7 +50,7 @@ jobs:
echo "[SUCCESS] Built $(ls ./wheelhouse/*.whl | wc -l) wheels."
shell: bash

- uses: actions/upload-artifact@v6
- uses: actions/upload-artifact@v7
with:
name: wheels-${{ matrix.os }}
path: ./wheelhouse/*.whl
Expand All @@ -58,12 +59,12 @@ jobs:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7

- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v6
- uses: actions/upload-artifact@v7
with:
name: sdist
path: dist/*.tar.gz
Expand All @@ -76,9 +77,9 @@ jobs:
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v7
- uses: actions/download-artifact@v8
with:
pattern: "*"
pattern: '*'
merge-multiple: true
path: dist

Expand Down
35 changes: 19 additions & 16 deletions .github/workflows/test-and-lint.yml → .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
# THIS WORKFLOW WILL INSTALL PYTHON DEPENDENCIES, RUN TESTS AND LINT WITH A VARIETY OF PYTHON VERSIONS
# FOR MORE INFORMATION SEE: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
# This workflow will install Python dependencies, run tests and lint with all supported Python versions.
# See: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Test & Lint
name: CI
permissions:
contents: read

on:
push:
branches: ["main"]
branches: [main]
pull_request:
branches: ["main"]
branches: [main]

jobs:
build:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
python-version: ['3.12', '3.13', '3.14']

steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}

- name: Cache pip packages
uses: actions/cache@v5
uses: actions/cache@v6
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt', '**/pyproject.toml') }}
Expand All @@ -40,17 +43,17 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install .[dev]
pip install flake8 flake8-pyproject pyright pytest
pip install ruff pyright pytest

- name: Lint with flake8
- name: Validate code with Ruff
run: |
python -m flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
python -m flake8 . --exit-zero --max-complexity=12 --statistics
python -m ruff check .
python -m ruff format --check .

- name: Type check with pyright
- name: Type check with PyRight
run: |
pyright
python -m pyright

- name: Test with pytest
- name: Test with PyTest
run: |
python -m pytest --verbose
66 changes: 66 additions & 0 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Deploy Documentation to GitHub Pages

on:
push:
branches: ['main']
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: 'pages'
cancel-in-progress: true

jobs:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7

- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: '3.14'

- name: Install xulbux dependencies
run: |
pip install -e .

- name: Install pnpm
uses: pnpm/action-setup@v6
with:
version: 11

- name: Set up Node
uses: actions/setup-node@v7
with:
node-version: 26
cache: 'pnpm'
cache-dependency-path: docs/pnpm-lock.yaml

- name: Install docs dependencies
working-directory: ./docs
run: pnpm install --frozen-lockfile

- name: Build docs
run: python docs/build.py

- name: Setup Pages
uses: actions/configure-pages@v6

- name: Upload artifact
uses: actions/upload-pages-artifact@v5
with:
# Upload the dist folder generated by VitePress:
path: './docs/.build/.vitepress/dist'

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5
14 changes: 11 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
# COMPILED FILES & CACHES
# Compiled files & caches
__pycache__/
__pypackages__/
.mypy_cache/
.pytest_cache/
.pytest_tmp/
.ruff_cache/
*.py[cdio]
*$py.class

# BUILD ARTIFACTS
# Build artifacts
*.egg-info/
build/
dist/

# TESTING
# Virtual environments
.venv/

# Documentation
docs/.build/
docs/node_modules/
docs/src/.vitepress/cache/
docs/src/.vitepress/dist/
19 changes: 0 additions & 19 deletions .style.yapf

This file was deleted.

Loading