pythonwrench 0.6.7__tar.gz → 0.6.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/.github/workflows/test.yaml +3 -3
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/.pre-commit-config.yaml +1 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/CHANGELOG.md +30 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/CITATION.cff +2 -2
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/PKG-INFO +8 -5
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/README.md +1 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.serialization.rst +8 -0
- pythonwrench-0.6.9/docs/pythonwrench.serialization.yaml.definitions.rst +7 -0
- pythonwrench-0.6.9/docs/pythonwrench.serialization.yaml.func.rst +7 -0
- pythonwrench-0.6.9/docs/pythonwrench.serialization.yaml.rst +16 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/pyproject.toml +22 -7
- pythonwrench-0.6.9/pythonwrench.code-workspace +13 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/setup.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/__init__.py +28 -6
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/__main__.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/_core.py +138 -10
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/abc.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/argparse/__init__.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/argparse/dataclass_.py +210 -48
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/argparse/parsers.py +24 -40
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/cast.py +8 -16
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/checksum.py +0 -4
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/collections/__init__.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/collections/collections.py +33 -54
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/collections/prop.py +0 -3
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/collections/reducers.py +2 -24
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/concurrent.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/csv.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/dataclasses.py +70 -4
- pythonwrench-0.6.9/src/pythonwrench/datetime.py +19 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/difflib.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/disk_cache.py +1 -23
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/entrypoints/info.py +2 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/entrypoints/safe_rmdir.py +45 -57
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/entrypoints/tree.py +26 -45
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/enum.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/functools.py +8 -38
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/hashlib.py +40 -10
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/importlib.py +15 -9
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/inspect.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/json.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/jsonl.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/logging.py +2 -3
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/math.py +0 -2
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/os.py +44 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/pickle.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/random.py +0 -3
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/re.py +75 -5
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/semver.py +31 -15
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/serialization/__init__.py +17 -2
- pythonwrench-0.6.9/src/pythonwrench/serialization/_core.py +412 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/serialization/csv.py +188 -207
- pythonwrench-0.6.9/src/pythonwrench/serialization/json.py +249 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/serialization/jsonl.py +109 -97
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/serialization/pickle.py +96 -96
- pythonwrench-0.6.9/src/pythonwrench/serialization/yaml/__init__.py +48 -0
- pythonwrench-0.6.9/src/pythonwrench/serialization/yaml/_yaml_fallback.py +63 -0
- pythonwrench-0.6.9/src/pythonwrench/serialization/yaml/definitions.py +81 -0
- pythonwrench-0.6.9/src/pythonwrench/serialization/yaml/func.py +318 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/time.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/typing/__init__.py +2 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/typing/checks.py +159 -72
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/src/pythonwrench/typing/classes.py +0 -1
- pythonwrench-0.6.9/src/pythonwrench/warnings.py +7 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/tests/test_abc.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/tests/test_argparse.py +124 -29
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/tests/test_cast.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/tests/test_checksum.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/tests/test_collections.py +16 -8
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/tests/test_core.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/tests/test_dataclasses.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/tests/test_difflib.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/tests/test_disk_cache.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/tests/test_entrypoints.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/tests/test_enum.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/tests/test_functools.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/tests/test_hashlib.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/tests/test_importlib.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/tests/test_inspect.py +1 -2
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/tests/test_logging.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/tests/test_math.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/tests/test_os.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/tests/test_random.py +0 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/tests/test_readme.py +2 -1
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/tests/test_semver.py +0 -1
- pythonwrench-0.6.9/tests/test_serialization.py +126 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/tests/test_typing.py +69 -23
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/uv.lock +2376 -2422
- pythonwrench-0.6.7/src/pythonwrench/datetime.py +0 -17
- pythonwrench-0.6.7/src/pythonwrench/serialization/_core.py +0 -73
- pythonwrench-0.6.7/src/pythonwrench/serialization/json.py +0 -216
- pythonwrench-0.6.7/src/pythonwrench/warnings.py +0 -118
- pythonwrench-0.6.7/tests/test_csv.py +0 -38
- pythonwrench-0.6.7/tests/test_json.py +0 -24
- pythonwrench-0.6.7/tests/test_jsonl.py +0 -18
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/.gitignore +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/.readthedocs.yaml +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/LICENSE +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/Makefile +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/conf.py +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/index.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/make.bat +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/modules.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.abc.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.argparse.dataclass_.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.argparse.parsers.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.argparse.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.cast.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.checksum.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.collections.collections.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.collections.prop.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.collections.reducers.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.collections.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.concurrent.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.csv.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.dataclasses.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.datetime.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.difflib.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.disk_cache.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.enum.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.functools.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.hashlib.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.importlib.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.inspect.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.json.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.jsonl.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.logging.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.math.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.os.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.pickle.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.random.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.re.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.semver.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.serialization.csv.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.serialization.json.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.serialization.jsonl.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.serialization.pickle.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.time.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.typing.checks.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.typing.classes.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.typing.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/pythonwrench.warnings.rst +0 -0
- {pythonwrench-0.6.7 → pythonwrench-0.6.9}/docs/update.bash +0 -0
|
@@ -25,16 +25,16 @@ jobs:
|
|
|
25
25
|
strategy:
|
|
26
26
|
matrix:
|
|
27
27
|
os: [ubuntu-24.04]
|
|
28
|
-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
|
|
28
|
+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "3.15"]
|
|
29
29
|
include:
|
|
30
30
|
- os: windows-2022
|
|
31
31
|
python-version: "3.8"
|
|
32
32
|
- os: windows-latest
|
|
33
|
-
python-version: "3.
|
|
33
|
+
python-version: "3.15"
|
|
34
34
|
- os: macos-15
|
|
35
35
|
python-version: "3.8"
|
|
36
36
|
- os: macos-latest
|
|
37
|
-
python-version: "3.
|
|
37
|
+
python-version: "3.15"
|
|
38
38
|
|
|
39
39
|
steps:
|
|
40
40
|
# --- INSTALLATIONS ---
|
|
@@ -2,6 +2,36 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.6.9] 2026-11-21
|
|
6
|
+
### Added
|
|
7
|
+
- Support Python 3.15.
|
|
8
|
+
- `hash_str`, `hash_bytes` and `hash_bytes_buffer` functions.
|
|
9
|
+
- Function `parse_args_using_dataclass` now supports metadata doc options.
|
|
10
|
+
- `key` arg in `filter_iter_with_patterns`.
|
|
11
|
+
- Serialisation function for YAML files.
|
|
12
|
+
- `on_exists` option for serialization fns.
|
|
13
|
+
- `module_fallback` option to `import_if_available` fn.
|
|
14
|
+
- support for TypeAliasType in `isinstance_generic`.
|
|
15
|
+
|
|
16
|
+
### Modified
|
|
17
|
+
- Update code format with ruff 0.16.10.
|
|
18
|
+
- Add check for `field.kw_only` with positional argument.
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
- Option value `posonly_for_required=True` in `parse_args_using_dataclass`.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## [0.6.8] 2026-10-26
|
|
25
|
+
### Added
|
|
26
|
+
- `remove_children` function to remove all content of a directory.
|
|
27
|
+
- `filter_dict_with_patterns` function.
|
|
28
|
+
- `parse_args_using_dataclass` and `add_dataclass_fields_to_parser` functions now supports nested dataclasses with subparsers.
|
|
29
|
+
|
|
30
|
+
### Modified
|
|
31
|
+
- `Version` is now converted to str by default in `as_builtin`.
|
|
32
|
+
- `isinstance_generic` now raises explicit exception when forwarded ref is given.
|
|
33
|
+
|
|
34
|
+
|
|
5
35
|
## [0.6.7] 2026-09-07
|
|
6
36
|
### Added
|
|
7
37
|
- `on_error` and `default` arguments to `load_json`, `load_pickle`, `load_jsonl` functions.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: pythonwrench
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.9
|
|
4
4
|
Summary: Python library with tools for typing, manipulating collections, and more!
|
|
5
5
|
Project-URL: Homepage, https://pypi.org/project/pythonwrench/
|
|
6
6
|
Project-URL: Documentation, https://pythonwrench.readthedocs.io/
|
|
@@ -46,8 +46,9 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
46
46
|
Classifier: Programming Language :: Python :: 3.12
|
|
47
47
|
Classifier: Programming Language :: Python :: 3.13
|
|
48
48
|
Classifier: Programming Language :: Python :: 3.14
|
|
49
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
49
50
|
Classifier: Topic :: Scientific/Engineering
|
|
50
|
-
Requires-Python: <3.
|
|
51
|
+
Requires-Python: <3.16,>=3.8
|
|
51
52
|
Requires-Dist: typing-extensions>=4.10.0
|
|
52
53
|
Provides-Extra: dev
|
|
53
54
|
Requires-Dist: coverage[toml]>=7.6.1; extra == 'dev'
|
|
@@ -56,7 +57,7 @@ Requires-Dist: ipython>=8.12.3; extra == 'dev'
|
|
|
56
57
|
Requires-Dist: pandas>=2.0.3; extra == 'dev'
|
|
57
58
|
Requires-Dist: pre-commit>=3.5.0; extra == 'dev'
|
|
58
59
|
Requires-Dist: pytest>=8.3.5; extra == 'dev'
|
|
59
|
-
Requires-Dist: ruff
|
|
60
|
+
Requires-Dist: ruff==0.16.10; extra == 'dev'
|
|
60
61
|
Requires-Dist: sphinx-immaterial>=0.11.14; extra == 'dev'
|
|
61
62
|
Requires-Dist: sphinx<9.0.0,>=7.1.2; extra == 'dev'
|
|
62
63
|
Requires-Dist: twine>=6.1.0; extra == 'dev'
|
|
@@ -68,7 +69,9 @@ Requires-Dist: lazy-loader<1,>=0.4; extra == 'lazy'
|
|
|
68
69
|
Provides-Extra: tests
|
|
69
70
|
Requires-Dist: coverage[toml]>=7.6.1; extra == 'tests'
|
|
70
71
|
Requires-Dist: pytest>=8.3.5; extra == 'tests'
|
|
71
|
-
Requires-Dist: ruff
|
|
72
|
+
Requires-Dist: ruff==0.16.10; extra == 'tests'
|
|
73
|
+
Provides-Extra: yaml
|
|
74
|
+
Requires-Dist: pyyaml>=6.0.3; extra == 'yaml'
|
|
72
75
|
Description-Content-Type: text/markdown
|
|
73
76
|
|
|
74
77
|
# pythonwrench
|
|
@@ -102,7 +105,7 @@ With pip:
|
|
|
102
105
|
pip install pythonwrench
|
|
103
106
|
```
|
|
104
107
|
|
|
105
|
-
This library has been tested on all Python versions **3.8 - 3.
|
|
108
|
+
This library has been tested on all Python versions **3.8 - 3.15**, requires only `typing_extensions>=4.10.0`, and runs on **Linux, Mac and Windows** systems.
|
|
106
109
|
|
|
107
110
|
## Examples
|
|
108
111
|
|
|
@@ -29,7 +29,7 @@ With pip:
|
|
|
29
29
|
pip install pythonwrench
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
This library has been tested on all Python versions **3.8 - 3.
|
|
32
|
+
This library has been tested on all Python versions **3.8 - 3.15**, requires only `typing_extensions>=4.10.0`, and runs on **Linux, Mac and Windows** systems.
|
|
33
33
|
|
|
34
34
|
## Examples
|
|
35
35
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
pythonwrench.serialization.yaml package
|
|
2
|
+
=======================================
|
|
3
|
+
|
|
4
|
+
.. automodule:: pythonwrench.serialization.yaml
|
|
5
|
+
:members:
|
|
6
|
+
:undoc-members:
|
|
7
|
+
:show-inheritance:
|
|
8
|
+
|
|
9
|
+
Submodules
|
|
10
|
+
----------
|
|
11
|
+
|
|
12
|
+
.. toctree::
|
|
13
|
+
:maxdepth: 4
|
|
14
|
+
|
|
15
|
+
pythonwrench.serialization.yaml.definitions
|
|
16
|
+
pythonwrench.serialization.yaml.func
|
|
@@ -5,7 +5,7 @@ authors = [
|
|
|
5
5
|
]
|
|
6
6
|
description = "Python library with tools for typing, manipulating collections, and more!"
|
|
7
7
|
readme = "README.md"
|
|
8
|
-
requires-python = ">=3.8,<3.
|
|
8
|
+
requires-python = ">=3.8,<3.16"
|
|
9
9
|
keywords = ["python", "tools", "utilities"]
|
|
10
10
|
license = {file = "LICENSE"}
|
|
11
11
|
# license-files = ["LICENSE"] # unsupported by python 3.8, but will be required in 2026
|
|
@@ -20,6 +20,7 @@ classifiers = [
|
|
|
20
20
|
"Programming Language :: Python :: 3.12",
|
|
21
21
|
"Programming Language :: Python :: 3.13",
|
|
22
22
|
"Programming Language :: Python :: 3.14",
|
|
23
|
+
"Programming Language :: Python :: 3.15",
|
|
23
24
|
"Topic :: Scientific/Engineering",
|
|
24
25
|
"Operating System :: OS Independent",
|
|
25
26
|
"Operating System :: MacOS :: MacOS X",
|
|
@@ -67,13 +68,16 @@ docs = [
|
|
|
67
68
|
"sphinx-immaterial>=0.11.14",
|
|
68
69
|
]
|
|
69
70
|
tests = [
|
|
70
|
-
"ruff
|
|
71
|
+
"ruff==0.16.10",
|
|
71
72
|
"coverage[toml]>=7.6.1",
|
|
72
73
|
"pytest>=8.3.5",
|
|
73
74
|
]
|
|
74
75
|
lazy = [
|
|
75
76
|
"lazy-loader>=0.4,<1",
|
|
76
77
|
]
|
|
78
|
+
yaml = [
|
|
79
|
+
"pyyaml>=6.0.3",
|
|
80
|
+
]
|
|
77
81
|
|
|
78
82
|
[tool.pyright]
|
|
79
83
|
include = ["src"]
|
|
@@ -86,11 +90,6 @@ testpaths = ["tests"]
|
|
|
86
90
|
[tool.coverage.run]
|
|
87
91
|
source = ["src"]
|
|
88
92
|
|
|
89
|
-
[tool.ruff.lint.extend-per-file-ignores]
|
|
90
|
-
# F401: module imported but unused
|
|
91
|
-
# F403: ‘from module import *’ used; unable to detect undefined names
|
|
92
|
-
"__init__.py" = ["F401", "F403"]
|
|
93
|
-
|
|
94
93
|
[tool.uv.sources]
|
|
95
94
|
pythonwrench = { workspace = true }
|
|
96
95
|
|
|
@@ -109,3 +108,19 @@ packages = ["src/pythonwrench"]
|
|
|
109
108
|
|
|
110
109
|
[tool.hatch.version]
|
|
111
110
|
path = "src/pythonwrench/__init__.py"
|
|
111
|
+
|
|
112
|
+
[tool.ruff]
|
|
113
|
+
# In addition to the standard set of exclusions, omit all tests, plus a specific file.
|
|
114
|
+
extend-exclude = ["notebooks/**.ipynb"]
|
|
115
|
+
|
|
116
|
+
[tool.ruff.lint.per-file-ignores]
|
|
117
|
+
# F401 : unused imports
|
|
118
|
+
# E402 : module import not at top of file
|
|
119
|
+
# UP009 : remove unnecessary utf-8 coding
|
|
120
|
+
# EXE001 : specify sheshang but file is not executable
|
|
121
|
+
# PYI061 : replace Literal[None, ...] by Literal[...] | None
|
|
122
|
+
# FA100 : Add `from __future__ import annotations` to simplify `typing.Dict`
|
|
123
|
+
# PLC0105: `TypeVar` name "T_BuiltinScalar" does not reflect its covariance; consider renaming it to "T_BuiltinScalar_co"
|
|
124
|
+
"__init__.py" = ["F401"]
|
|
125
|
+
"notebooks/**.ipynb" = ["E402"]
|
|
126
|
+
"*.py" = ["UP009", "EXE001", "PYI061", "FA100", "PLC0105"]
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
2
|
|
|
4
3
|
"""Python library with tools for typing, manipulating collections, and more!"""
|
|
5
4
|
|
|
@@ -9,7 +8,7 @@ __author_email__ = "labbeti.pub@gmail.com"
|
|
|
9
8
|
__license__ = "MIT"
|
|
10
9
|
__maintainer__ = "Étienne Labbé (Labbeti)"
|
|
11
10
|
__status__ = "Development"
|
|
12
|
-
__version__ = "0.6.
|
|
11
|
+
__version__ = "0.6.9"
|
|
13
12
|
|
|
14
13
|
|
|
15
14
|
from typing import TYPE_CHECKING
|
|
@@ -127,7 +126,7 @@ if TYPE_CHECKING or lazy is None:
|
|
|
127
126
|
identity,
|
|
128
127
|
repeat_fn,
|
|
129
128
|
)
|
|
130
|
-
from .hashlib import hash_file
|
|
129
|
+
from .hashlib import hash_bytes, hash_bytes_buffer, hash_file, hash_str
|
|
131
130
|
from .importlib import (
|
|
132
131
|
ModulePlaceholder,
|
|
133
132
|
Placeholder,
|
|
@@ -157,12 +156,14 @@ if TYPE_CHECKING or lazy is None:
|
|
|
157
156
|
setup_logging_verbose,
|
|
158
157
|
)
|
|
159
158
|
from .math import argmax, argmin, argsort, clamp, clip
|
|
160
|
-
from .os import get_num_cpus_available, safe_rmdir, tree_iter
|
|
159
|
+
from .os import get_num_cpus_available, remove_children, safe_rmdir, tree_iter
|
|
161
160
|
from .random import randstr
|
|
162
161
|
from .re import (
|
|
163
162
|
PatternLike,
|
|
164
163
|
PatternListLike,
|
|
165
164
|
compile_patterns,
|
|
165
|
+
filter_dict_with_patterns,
|
|
166
|
+
filter_iter_with_patterns,
|
|
166
167
|
filter_with_patterns,
|
|
167
168
|
find_patterns,
|
|
168
169
|
get_key_fn,
|
|
@@ -175,26 +176,32 @@ if TYPE_CHECKING or lazy is None:
|
|
|
175
176
|
dump_json,
|
|
176
177
|
dump_jsonl,
|
|
177
178
|
dump_pickle,
|
|
179
|
+
dump_yaml,
|
|
178
180
|
dumps_csv,
|
|
179
181
|
dumps_json,
|
|
180
182
|
dumps_jsonl,
|
|
181
183
|
dumps_pickle,
|
|
184
|
+
dumps_yaml,
|
|
182
185
|
load_csv,
|
|
183
186
|
load_json,
|
|
184
187
|
load_jsonl,
|
|
185
188
|
load_pickle,
|
|
189
|
+
load_yaml,
|
|
186
190
|
loads_csv,
|
|
187
191
|
loads_json,
|
|
188
192
|
loads_jsonl,
|
|
189
193
|
loads_pickle,
|
|
194
|
+
loads_yaml,
|
|
190
195
|
read_csv,
|
|
191
196
|
read_json,
|
|
192
197
|
read_jsonl,
|
|
193
198
|
read_pickle,
|
|
199
|
+
read_yaml,
|
|
194
200
|
save_csv,
|
|
195
201
|
save_json,
|
|
196
202
|
save_jsonl,
|
|
197
203
|
save_pickle,
|
|
204
|
+
save_yaml,
|
|
198
205
|
)
|
|
199
206
|
from .time import Ticker
|
|
200
207
|
from .typing import (
|
|
@@ -245,6 +252,7 @@ if TYPE_CHECKING or lazy is None:
|
|
|
245
252
|
is_special_form,
|
|
246
253
|
is_typed_dict,
|
|
247
254
|
isinstance_generic,
|
|
255
|
+
isinstance_parametrized,
|
|
248
256
|
)
|
|
249
257
|
from .warnings import deprecated_alias, deprecated_function, warn_once
|
|
250
258
|
|
|
@@ -370,6 +378,12 @@ else:
|
|
|
370
378
|
"save_json",
|
|
371
379
|
"save_jsonl",
|
|
372
380
|
"save_pickle",
|
|
381
|
+
"dump_yaml",
|
|
382
|
+
"dumps_yaml",
|
|
383
|
+
"load_yaml",
|
|
384
|
+
"loads_yaml",
|
|
385
|
+
"read_yaml",
|
|
386
|
+
"save_yaml",
|
|
373
387
|
],
|
|
374
388
|
"dataclasses": ["add_dict_methods", "dataclassdict", "get_defaults_values"],
|
|
375
389
|
"datetime": ["get_now", "get_now_iso8601"],
|
|
@@ -384,7 +398,7 @@ else:
|
|
|
384
398
|
"identity",
|
|
385
399
|
"repeat_fn",
|
|
386
400
|
],
|
|
387
|
-
"hashlib": ["hash_file"],
|
|
401
|
+
"hashlib": ["hash_file", "hash_bytes", "hash_bytes_buffer", "hash_str"],
|
|
388
402
|
"importlib": [
|
|
389
403
|
"import_if_available",
|
|
390
404
|
"ModulePlaceholder",
|
|
@@ -414,13 +428,20 @@ else:
|
|
|
414
428
|
"setup_logging_verbose",
|
|
415
429
|
],
|
|
416
430
|
"math": ["argmax", "argmin", "argsort", "clamp", "clip"],
|
|
417
|
-
"os": [
|
|
431
|
+
"os": [
|
|
432
|
+
"get_num_cpus_available",
|
|
433
|
+
"remove_children",
|
|
434
|
+
"safe_rmdir",
|
|
435
|
+
"tree_iter",
|
|
436
|
+
],
|
|
418
437
|
"random": ["randstr"],
|
|
419
438
|
"re": [
|
|
420
439
|
"PatternLike",
|
|
421
440
|
"PatternListLike",
|
|
422
441
|
"compile_patterns",
|
|
423
442
|
"filter_with_patterns",
|
|
443
|
+
"filter_iter_with_patterns",
|
|
444
|
+
"filter_dict_with_patterns",
|
|
424
445
|
"find_patterns",
|
|
425
446
|
"get_key_fn",
|
|
426
447
|
"match_patterns",
|
|
@@ -476,6 +497,7 @@ else:
|
|
|
476
497
|
"is_special_form",
|
|
477
498
|
"is_typed_dict",
|
|
478
499
|
"isinstance_generic",
|
|
500
|
+
"isinstance_parametrized",
|
|
479
501
|
],
|
|
480
502
|
"warnings": ["deprecated_alias", "deprecated_function", "warn_once"],
|
|
481
503
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
import warnings
|
|
4
|
+
from functools import lru_cache, partial, wraps
|
|
5
5
|
from typing import (
|
|
6
6
|
Any,
|
|
7
7
|
Callable,
|
|
@@ -11,8 +11,10 @@ from typing import (
|
|
|
11
11
|
Optional,
|
|
12
12
|
Protocol,
|
|
13
13
|
Tuple,
|
|
14
|
+
Type,
|
|
14
15
|
Union,
|
|
15
16
|
get_args,
|
|
17
|
+
overload,
|
|
16
18
|
runtime_checkable,
|
|
17
19
|
)
|
|
18
20
|
|
|
@@ -21,6 +23,7 @@ from typing_extensions import ParamSpec, TypeVar
|
|
|
21
23
|
P = ParamSpec("P")
|
|
22
24
|
T = TypeVar("T", covariant=True)
|
|
23
25
|
U = TypeVar("U", covariant=True)
|
|
26
|
+
|
|
24
27
|
T_Output = TypeVar("T_Output", default=Any)
|
|
25
28
|
T_PredicateArg = TypeVar("T_PredicateArg", contravariant=True, default=Any)
|
|
26
29
|
T_Function = TypeVar("T_Function", bound=Callable[..., Any])
|
|
@@ -38,7 +41,32 @@ class Predicate(Protocol[T_PredicateArg]):
|
|
|
38
41
|
|
|
39
42
|
def return_none(*args, **kwargs) -> None:
|
|
40
43
|
"""Return None function placeholder."""
|
|
41
|
-
return
|
|
44
|
+
return
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def function_alias(
|
|
48
|
+
alternative: T_Function,
|
|
49
|
+
*,
|
|
50
|
+
pre_fn: Optional[Callable[..., Any]] = None,
|
|
51
|
+
post_fn: Optional[Callable[..., Any]] = None,
|
|
52
|
+
) -> Callable[..., T_Function]:
|
|
53
|
+
"""Decorator to wrap function aliases.
|
|
54
|
+
|
|
55
|
+
Unlike setting directly an alias, this preserve the nature of the alias for language server.
|
|
56
|
+
|
|
57
|
+
Example
|
|
58
|
+
-------
|
|
59
|
+
>>> def f(a: int, b: str) -> str:
|
|
60
|
+
>>> return a * b
|
|
61
|
+
>>> @function_alias(f)
|
|
62
|
+
>>> def g(*args, **kwargs): ...
|
|
63
|
+
>>> f(2, "a")
|
|
64
|
+
... "aa"
|
|
65
|
+
>>> g(3, "b") # calls function f() internally.
|
|
66
|
+
... "bbb"
|
|
67
|
+
|
|
68
|
+
"""
|
|
69
|
+
return _decorator_factory(alternative, pre_fn=pre_fn, post_fn=post_fn)
|
|
42
70
|
|
|
43
71
|
|
|
44
72
|
def _decorator_factory(
|
|
@@ -133,18 +161,17 @@ class _FunctionRegistry(Generic[T_Output]):
|
|
|
133
161
|
unk_mode: UnkMode = "error",
|
|
134
162
|
**kwargs,
|
|
135
163
|
) -> T_Output:
|
|
136
|
-
|
|
164
|
+
def wrapped_isinstance(x: Any, target_cls_or_tuple: Any) -> bool:
|
|
165
|
+
return isinstance_fn(x, target_cls_or_tuple)
|
|
166
|
+
|
|
137
167
|
for fn, (class_or_tuple, custom_predicate, _) in self.fns.items():
|
|
138
168
|
if custom_predicate is not None:
|
|
139
169
|
predicate = custom_predicate
|
|
140
170
|
|
|
141
171
|
elif class_or_tuple is not None:
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
return isinstance_fn(x, class_or_tuple) # type: ignore
|
|
146
|
-
|
|
147
|
-
predicate = target_isinstance_fn_wrap
|
|
172
|
+
predicate = partial(
|
|
173
|
+
wrapped_isinstance, target_cls_or_tuple=class_or_tuple
|
|
174
|
+
)
|
|
148
175
|
else:
|
|
149
176
|
msg = f"Invalid function registered. (found {class_or_tuple=} and {custom_predicate=})"
|
|
150
177
|
raise TypeError(msg)
|
|
@@ -190,3 +217,104 @@ def _get_insertion_index(lst: list, priority: int, priority_key: int) -> int:
|
|
|
190
217
|
if priority >= other_priority:
|
|
191
218
|
return i
|
|
192
219
|
return len(lst)
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
@overload
|
|
223
|
+
def warn_once(
|
|
224
|
+
message: str,
|
|
225
|
+
category: Optional[Type[Warning]] = None,
|
|
226
|
+
stacklevel: int = 1,
|
|
227
|
+
source: Any = None,
|
|
228
|
+
) -> None:
|
|
229
|
+
"""Warn message once using warnings module."""
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
@overload
|
|
233
|
+
def warn_once(
|
|
234
|
+
message: Warning,
|
|
235
|
+
category: Any = None,
|
|
236
|
+
stacklevel: int = 1,
|
|
237
|
+
source: Any = None,
|
|
238
|
+
) -> None:
|
|
239
|
+
"""Warn message once using warnings module."""
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
@lru_cache(maxsize=None)
|
|
243
|
+
def warn_once(
|
|
244
|
+
message: Union[str, Warning],
|
|
245
|
+
category: Optional[Type[Warning]] = None,
|
|
246
|
+
stacklevel: int = 1,
|
|
247
|
+
source: Any = None,
|
|
248
|
+
) -> None:
|
|
249
|
+
"""Warn message once using warnings module."""
|
|
250
|
+
warnings.warn(message, category, stacklevel, source)
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
def deprecated_alias(
|
|
254
|
+
alternative: T_Function,
|
|
255
|
+
msg_fmt: str = "Deprecated call to '{fn_name}', use '{alternative_name}' instead.",
|
|
256
|
+
warn_fn: Callable[[str], Any] = partial(warn_once, category=DeprecationWarning),
|
|
257
|
+
*,
|
|
258
|
+
pre_fn: Optional[Callable[..., Any]] = None,
|
|
259
|
+
post_fn: Optional[Callable[..., Any]] = None,
|
|
260
|
+
) -> Callable[..., T_Function]:
|
|
261
|
+
"""Decorator to wrap deprecated function aliases."""
|
|
262
|
+
alternative_name = alternative.__name__ if alternative is not None else "None"
|
|
263
|
+
if pre_fn is None:
|
|
264
|
+
pre_fn = return_none
|
|
265
|
+
|
|
266
|
+
def inner_pre_fn(fn, *args, **kwargs) -> None:
|
|
267
|
+
"""Perform the inner pre fn operation."""
|
|
268
|
+
msg = msg_fmt.format(fn_name=fn.__name__, alternative_name=alternative_name)
|
|
269
|
+
warn_fn(msg)
|
|
270
|
+
pre_fn(fn, *args, **kwargs)
|
|
271
|
+
|
|
272
|
+
return _decorator_factory(alternative, pre_fn=inner_pre_fn, post_fn=post_fn)
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
@overload
|
|
276
|
+
def deprecated_function(
|
|
277
|
+
fn: None = None,
|
|
278
|
+
/,
|
|
279
|
+
*,
|
|
280
|
+
msg_fmt: str = "Deprecated call to '{fn_name}'.",
|
|
281
|
+
warn_fn: Callable[[str], Any] = partial(warn_once, category=DeprecationWarning),
|
|
282
|
+
) -> Callable[[T_Function], T_Function]:
|
|
283
|
+
"""Perform the deprecated function operation."""
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
@overload
|
|
287
|
+
def deprecated_function(
|
|
288
|
+
fn: T_Function,
|
|
289
|
+
/,
|
|
290
|
+
*,
|
|
291
|
+
msg_fmt: str = "Deprecated call to '{fn_name}'.",
|
|
292
|
+
warn_fn: Callable[[str], Any] = partial(warn_once, category=DeprecationWarning),
|
|
293
|
+
) -> T_Function:
|
|
294
|
+
"""Perform the deprecated function operation."""
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
def deprecated_function(
|
|
298
|
+
fn: Optional[T_Function] = None,
|
|
299
|
+
/,
|
|
300
|
+
*,
|
|
301
|
+
msg_fmt: str = "Deprecated call to '{fn_name}'.",
|
|
302
|
+
warn_fn: Callable[[str], Any] = partial(warn_once, category=DeprecationWarning),
|
|
303
|
+
pre_fn: Optional[Callable[..., Any]] = None,
|
|
304
|
+
post_fn: Optional[Callable[..., Any]] = None,
|
|
305
|
+
) -> Union[Callable[[T_Function], T_Function], T_Function]:
|
|
306
|
+
"""Decorator to wrap deprecated functions."""
|
|
307
|
+
if pre_fn is None:
|
|
308
|
+
pre_fn = return_none
|
|
309
|
+
|
|
310
|
+
def inner_pre_fn(fn, *args, **kwargs):
|
|
311
|
+
"""Perform the inner pre fn operation."""
|
|
312
|
+
msg = msg_fmt.format(fn_name=fn.__qualname__)
|
|
313
|
+
warn_fn(msg)
|
|
314
|
+
pre_fn(fn, *args, **kwargs)
|
|
315
|
+
|
|
316
|
+
decorator = _decorator_factory(None, pre_fn=inner_pre_fn, post_fn=post_fn)
|
|
317
|
+
if fn is None:
|
|
318
|
+
return decorator
|
|
319
|
+
else:
|
|
320
|
+
return decorator(fn)
|