Skip to content

Commit ff21592

Browse files
authored
Merge release v1.9.7 into main
Merge version 1.9.7 of 'xulbux' into the main branch. For more info on this update, see the change log: https://github.com/xulbux/python-lib-xulbux/blob/main/CHANGELOG.md#v1-9-7
2 parents f86d16e + 8bc0545 commit ff21592

23 files changed

Lines changed: 520 additions & 122 deletions

.github/workflows/build-and-publish.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# THIS WORKFLOW WILL BUILD WHEELS FOR ALL MAJOR PLATFORMS AND UPLOAD THEM TO PYPI
22

33
# TO BUILD AND INSTALL LOCALLY FOR TESTING, RUN THE FOLLOWING COMMAND:
4-
# pip install "/path/to/python-lib-xulbux" --no-deps --no-cache-dir --force-reinstall --no-build-isolation
4+
# py -m pip install "/path/to/python-lib-xulbux" --no-deps --no-cache-dir --force-reinstall -vv
55

66
# TO CREATE A NEW RELEASE, TAG A COMMIT WITH THE FOLLOWING FORMAT:
77
# git tag v1.X.Y
@@ -36,8 +36,7 @@ jobs:
3636
env:
3737
CIBW_BUILD: cp310-* cp311-* cp312-* cp313-* cp314-*
3838
CIBW_SKIP: "*-musllinux_*"
39-
CIBW_BEFORE_BUILD: pip install setuptools>=80.0.0 wheel>=0.45.0 mypy>=1.19.0 mypy-extensions>=1.1.0 types-regex types-keyboard prompt_toolkit>=3.0.41
40-
CIBW_BUILD_FRONTEND: "pip; args: --no-build-isolation"
39+
CIBW_BUILD_FRONTEND: pip
4140
CIBW_ENVIRONMENT: XULBUX_USE_MYPYC=1
4241

4342
- name: Verify wheels were built

.github/workflows/test-and-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
- name: Install project and dependencies
4040
run: |
4141
python -m pip install --upgrade pip
42-
pip install -e .[dev]
42+
pip install .[dev]
4343
pip install flake8 flake8-pyproject pyright pytest
4444
4545
- name: Lint with flake8

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,28 @@
1515
# <br><b>Changelog</b><br>
1616

1717

18+
<span id="v1-9-7" />
19+
20+
## 26.04.2026 `v1.9.7`
21+
22+
* Restructured CLI commands under a single `xulbux-lib` entry point:
23+
- `xulbux-lib` shows library info.
24+
- `xulbux-lib fc` (*new*) parses and renders a string's format codes as ANSI console output.
25+
* Added `.get()` method to `ParsedArgData` for safe index access on parsed argument values.
26+
* Added missing `__init__.py` files to the `base` and `cli` subpackages.
27+
* Fixed `ModuleNotFoundError` caused by `mypyc` compiling `__init__.py` files, which broke subpackage imports.
28+
* Simplified CI workflows to use `pip`'s build isolation instead of manually specifying build dependencies.
29+
* Fixed a small bug in `ProgressBar`, where it would only overwrite and not actually clear the previous line.
30+
* Added a new constant `ANSI.COLOR_VARIANTS_MAP`, which contains all possible color variants that can be used in formatting.
31+
* Made it possible to also pass console default colors to `title_bg_color` in `Console.log()`, instead of only custom RGBA or HEXA colors.
32+
* Added a new format key `link:…` to `FormatCodes`, which allows you to create hyperlinks in the console output with the syntax `[link:URL](display text)`.
33+
34+
**BREAKING CHANGES:**
35+
* The `ANSI.COLOR_MAP` constant is now a set for better lookup performance, as the color order doesn't matter there.
36+
* All `Console` methods that allow console default colors as input for their color params, now actually validate the given color, raising an error if it's not valid.
37+
* The default for `box_bg_color` in `Console.log_box_filled()` is now the console foreground color (`None`) instead of `br:green`.
38+
39+
1840
<span id="v1-9-6" />
1941

2042
## 13.04.2026 `v1.9.6`

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ pip install --upgrade xulbux
3434
## CLI Commands
3535

3636
When the library is installed, the following commands are available in the console:
37-
| Command | Description |
38-
| :------------ | :--------------------------------------- |
39-
| `xulbux-help` | shows some information about the library |
37+
38+
| Command | Description |
39+
| :---------------- | :--------------------------------------------------------------- |
40+
| `xulbux-lib` | Show some information about the library. |
41+
| `xulbux-lib fc` | Parse and render a string's format codes as ANSI console output. |
4042

4143
<br>
4244

pyproject.toml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,26 @@
11
[build-system]
2-
# SAME BUILD-DEPS ALSO NEED TO BE SPECIFIED IN CIBW_BEFORE_BUILD IN .github/workflows/build-and-publish.yml
32
requires = [
43
"setuptools>=80.0.0",
54
"wheel>=0.45.0",
65
"mypy>=1.19.0",
76
"mypy-extensions>=1.1.0",
87
# TYPES FOR MyPy
98
"types-regex",
10-
"types-keyboard",
119
"prompt_toolkit>=3.0.41",
1210
]
1311
build-backend = "setuptools.build_meta"
1412

1513
[project]
1614
name = "xulbux"
17-
version = "1.9.6"
15+
version = "1.9.7"
1816
description = "A Python library to simplify common programming tasks."
1917
readme = "README.md"
2018
authors = [{ name = "XulbuX", email = "xulbux.real@gmail.com" }]
2119
maintainers = [{ name = "XulbuX", email = "xulbux.real@gmail.com" }]
2220
license = "MIT"
2321
license-files = ["LICENSE"]
2422
requires-python = ">=3.10.0"
25-
dependencies = [
26-
"keyboard>=0.13.5",
27-
"prompt_toolkit>=3.0.41",
28-
"regex>=2023.10.3",
29-
]
23+
dependencies = ["prompt_toolkit>=3.0.41", "regex>=2023.10.3"]
3024
optional-dependencies = { dev = [
3125
"flake8-pyproject>=1.2.3",
3226
"flake8>=6.1.0",
@@ -116,7 +110,7 @@ keywords = [
116110
"License" = "https://github.com/xulbux/python-lib-xulbux/blob/main/LICENSE"
117111

118112
[project.scripts]
119-
xulbux-help = "xulbux.cli.help:show_help"
113+
xulbux-lib = "xulbux.cli:main"
120114

121115
[tool.flake8]
122116
max-complexity = 12
@@ -158,3 +152,4 @@ testpaths = [
158152
[tool.pyright]
159153
include = ["src", "tests"]
160154
typeCheckingMode = "strict"
155+
reportPrivateUsage = "none"

setup.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@
66
import os
77

88

9+
PROJECT_ROOT = Path(__file__).parent
10+
PROJECT_SRC = PROJECT_ROOT / "src" / "xulbux"
11+
12+
913
def find_python_files(directory: str) -> list[str]:
1014
python_files: list[str] = []
1115
for file in Path(directory).rglob("*.py"):
16+
if file.name == "__init__.py":
17+
continue
1218
python_files.append(str(file))
1319
return python_files
1420

@@ -18,17 +24,16 @@ def generate_stubs_for_package():
1824

1925
try:
2026
skip_stubgen = {
21-
Path("src/xulbux/base/types.py"), # COMPLEX TYPE DEFINITIONS
22-
Path("src/xulbux/__init__.py"), # PRESERVE PACKAGE METADATA CONSTANTS
27+
PROJECT_SRC / "base" / "types.py", # COMPLEX TYPE DEFINITIONS
28+
PROJECT_SRC / "__init__.py", # PRESERVE PACKAGE METADATA CONSTANTS
2329
}
2430

25-
src_dir = Path("src/xulbux")
2631
generated_count = 0
2732
skipped_count = 0
2833

29-
for py_file in src_dir.rglob("*.py"):
34+
for py_file in PROJECT_SRC.rglob("*.py"):
3035
pyi_file = py_file.with_suffix(".pyi")
31-
rel_path = py_file.relative_to(src_dir.parent)
36+
rel_path = py_file.relative_to(PROJECT_SRC.parent)
3237

3338
if py_file in skip_stubgen:
3439
pyi_file.write_text(py_file.read_text(encoding="utf-8"), encoding="utf-8")
@@ -41,13 +46,9 @@ def generate_stubs_for_package():
4146
or str(Path(sys.executable).parent / ("stubgen.exe" if sys.platform == "win32" else "stubgen"))
4247
)
4348
result = subprocess.run(
44-
[stubgen_exe,
45-
str(py_file),
46-
"-o", "src",
47-
"--include-private",
48-
"--export-less"],
49+
[stubgen_exe, str(py_file), "-o", "src", "--include-private", "--export-less"],
4950
capture_output=True,
50-
text=True
51+
text=True,
5152
)
5253

5354
if result.returncode == 0:
@@ -65,6 +66,11 @@ def generate_stubs_for_package():
6566
print(f"[WARNING] Could not generate stubs:\n {fmt_error}\n")
6667

6768

69+
def delete_project_stub_files():
70+
deleted = [f for f in PROJECT_SRC.rglob("*.pyi") if f.unlink() or True]
71+
print(f"\nCleaned up {len(deleted)} stub file(s) from project directory.\n")
72+
73+
6874
ext_modules = []
6975

7076
# OPTIONALLY USE MYPYC COMPILATION
@@ -90,3 +96,5 @@ def generate_stubs_for_package():
9096
name="xulbux",
9197
ext_modules=ext_modules,
9298
)
99+
100+
delete_project_stub_files()

src/xulbux/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__package_name__ = "xulbux"
2-
__version__ = "1.9.6"
2+
__version__ = "1.9.7"
33
__description__ = "A Python library to simplify common programming tasks."
44
__status__ = "Production/Stable"
55

@@ -12,7 +12,6 @@
1212

1313
__requires_python__ = ">=3.10.0"
1414
__dependencies__ = [
15-
"keyboard>=0.13.5",
1615
"prompt_toolkit>=3.0.41",
1716
"regex>=2023.10.3",
1817
]

src/xulbux/base/__init__.py

Whitespace-only changes.

src/xulbux/base/consts.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,12 @@ def seq(cls, placeholders: int = 1, /) -> FormattableString:
9797
SEQ_BG_COLOR: Final[FormattableString] = CHAR + START + "48" + SEP + "2" + SEP + "{}" + SEP + "{}" + SEP + "{}" + END
9898
"""ANSI escape sequence with three placeholders for setting the RGB background color."""
9999

100-
COLOR_MAP: Final[tuple[str, ...]] = (
101-
########### DEFAULT CONSOLE COLOR NAMES ############
100+
SEQ_LINK_OPEN: Final[FormattableString] = CHAR + "]8;;{}" + CHAR + "\\"
101+
"""OSC 8 hyperlink opening sequence with a placeholder for the URL."""
102+
SEQ_LINK_CLOSE: Final[str] = CHAR + "]8;;" + CHAR + "\\"
103+
"""OSC 8 hyperlink closing sequence."""
104+
105+
COLOR_MAP: Final[set[str]] = {
102106
"black",
103107
"red",
104108
"green",
@@ -107,9 +111,29 @@ def seq(cls, placeholders: int = 1, /) -> FormattableString:
107111
"magenta",
108112
"cyan",
109113
"white",
110-
)
114+
}
111115
"""The standard terminal color names."""
112116

117+
COLOR_VARIANTS_MAP: Final[set[str]] = COLOR_MAP | {
118+
"br:black",
119+
"br:red",
120+
"br:green",
121+
"br:yellow",
122+
"br:blue",
123+
"br:magenta",
124+
"br:cyan",
125+
"br:white",
126+
"bright:black",
127+
"bright:red",
128+
"bright:green",
129+
"bright:yellow",
130+
"bright:blue",
131+
"bright:magenta",
132+
"bright:cyan",
133+
"bright:white",
134+
}
135+
"""All color variants that can be used in formatting."""
136+
113137
CODES_MAP: Final[dict[str | tuple[str, ...], int]] = {
114138
################# SPECIFIC RESETS ##################
115139
"_": 0,

src/xulbux/base/exceptions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
from .decorators import mypyc_attr
66

7+
# yapf: disable
8+
79

810
################################################## FILE ##################################################
911

0 commit comments

Comments
 (0)