pythonwrench 0.5.2__tar.gz → 0.6.1__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.5.2/src/pythonwrench.egg-info → pythonwrench-0.6.1}/PKG-INFO +14 -2
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/pyproject.toml +26 -24
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/__init__.py +71 -55
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/__main__.py +2 -2
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/_core.py +6 -56
- pythonwrench-0.6.1/src/pythonwrench/argparse.py +553 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/collections/collections.py +7 -7
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/concurrent.py +6 -2
- pythonwrench-0.6.1/src/pythonwrench/csv.py +12 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/dataclasses.py +1 -1
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/difflib.py +9 -6
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/disk_cache.py +5 -3
- pythonwrench-0.6.1/src/pythonwrench/entrypoints/info.py +44 -0
- pythonwrench-0.6.1/src/pythonwrench/entrypoints/safe_rmdir.py +96 -0
- pythonwrench-0.6.1/src/pythonwrench/entrypoints/tree.py +112 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/functools.py +37 -9
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/importlib.py +39 -21
- pythonwrench-0.6.1/src/pythonwrench/json.py +12 -0
- pythonwrench-0.6.1/src/pythonwrench/jsonl.py +12 -0
- pythonwrench-0.6.1/src/pythonwrench/pickle.py +12 -0
- pythonwrench-0.6.1/src/pythonwrench/serialization/__init__.py +70 -0
- pythonwrench-0.6.1/src/pythonwrench/serialization/_core.py +60 -0
- {pythonwrench-0.5.2/src/pythonwrench → pythonwrench-0.6.1/src/pythonwrench/serialization}/csv.py +1 -1
- {pythonwrench-0.5.2/src/pythonwrench → pythonwrench-0.6.1/src/pythonwrench/serialization}/json.py +1 -1
- {pythonwrench-0.5.2/src/pythonwrench → pythonwrench-0.6.1/src/pythonwrench/serialization}/jsonl.py +3 -3
- {pythonwrench-0.5.2/src/pythonwrench → pythonwrench-0.6.1/src/pythonwrench/serialization}/pickle.py +1 -1
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/time.py +3 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/typing/__init__.py +2 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/typing/checks.py +13 -3
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/typing/classes.py +4 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/warnings.py +16 -5
- {pythonwrench-0.5.2 → pythonwrench-0.6.1/src/pythonwrench.egg-info}/PKG-INFO +14 -2
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench.egg-info/SOURCES.txt +10 -3
- pythonwrench-0.6.1/src/pythonwrench.egg-info/entry_points.txt +10 -0
- pythonwrench-0.6.1/src/pythonwrench.egg-info/requires.txt +18 -0
- pythonwrench-0.6.1/tests/test_argparse.py +154 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/tests/test_disk_cache.py +18 -0
- pythonwrench-0.5.2/tests/test_entries.py → pythonwrench-0.6.1/tests/test_entrypoints.py +2 -1
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/tests/test_functools.py +6 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/tests/test_typing.py +12 -0
- pythonwrench-0.5.2/docs/requirements.txt +0 -4
- pythonwrench-0.5.2/src/pythonwrench/argparse.py +0 -311
- pythonwrench-0.5.2/src/pythonwrench/entries.py +0 -223
- pythonwrench-0.5.2/src/pythonwrench.egg-info/entry_points.txt +0 -7
- pythonwrench-0.5.2/src/pythonwrench.egg-info/requires.txt +0 -6
- pythonwrench-0.5.2/tests/test_argparse.py +0 -67
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/LICENSE +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/README.md +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/setup.cfg +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/setup.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/abc.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/cast.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/checksum.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/collections/__init__.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/collections/prop.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/collections/reducers.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/datetime.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/enum.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/hashlib.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/inspect.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/logging.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/math.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/os.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/random.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/re.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench/semver.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench.egg-info/dependency_links.txt +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/src/pythonwrench.egg-info/top_level.txt +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/tests/test_abc.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/tests/test_cast.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/tests/test_checksum.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/tests/test_collections.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/tests/test_csv.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/tests/test_dataclasses.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/tests/test_difflib.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/tests/test_enum.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/tests/test_hashlib.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/tests/test_importlib.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/tests/test_inspect.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/tests/test_json.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/tests/test_jsonl.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/tests/test_logging.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/tests/test_math.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/tests/test_os.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/tests/test_random.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/tests/test_readme.py +0 -0
- {pythonwrench-0.5.2 → pythonwrench-0.6.1}/tests/test_semver.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pythonwrench
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.1
|
|
4
4
|
Summary: Python library with tools for typing, manipulating collections, and more!
|
|
5
5
|
Author-email: "Étienne Labbé (Labbeti)" <labbeti.pub@gmail.com>
|
|
6
6
|
Maintainer-email: "Étienne Labbé (Labbeti)" <labbeti.pub@gmail.com>
|
|
@@ -52,8 +52,20 @@ Description-Content-Type: text/markdown
|
|
|
52
52
|
License-File: LICENSE
|
|
53
53
|
Requires-Dist: typing-extensions>=4.10.0
|
|
54
54
|
Provides-Extra: dev
|
|
55
|
+
Requires-Dist: pandas>=2.0.3; extra == "dev"
|
|
56
|
+
Requires-Dist: coverage[toml]>=7.6.1; extra == "dev"
|
|
57
|
+
Requires-Dist: ruff>=0.12.0; extra == "dev"
|
|
58
|
+
Requires-Dist: sphinx<9.0.0; extra == "dev"
|
|
59
|
+
Requires-Dist: sphinx-immaterial>=0.11.14; extra == "dev"
|
|
60
|
+
Requires-Dist: flake8>=5.0.4; extra == "dev"
|
|
61
|
+
Requires-Dist: ipykernel>=6.29.5; extra == "dev"
|
|
62
|
+
Requires-Dist: ipython>=8.12.3; extra == "dev"
|
|
63
|
+
Requires-Dist: pre-commit>=3.5.0; extra == "dev"
|
|
64
|
+
Requires-Dist: pytest>=8.3.5; extra == "dev"
|
|
65
|
+
Requires-Dist: setuptools>=75.3.2; extra == "dev"
|
|
66
|
+
Requires-Dist: twine>=6.1.0; extra == "dev"
|
|
55
67
|
Provides-Extra: lazy
|
|
56
|
-
Requires-Dist: lazy-loader
|
|
68
|
+
Requires-Dist: lazy-loader<0.5,>=0.4; extra == "lazy"
|
|
57
69
|
Dynamic: license-file
|
|
58
70
|
|
|
59
71
|
# pythonwrench
|
|
@@ -42,17 +42,33 @@ Changelog = "https://github.com/Labbeti/pythonwrench/blob/main/CHANGELOG.md"
|
|
|
42
42
|
Tracker = "https://github.com/Labbeti/pythonwrench/issues"
|
|
43
43
|
|
|
44
44
|
[project.scripts]
|
|
45
|
-
pythonwrench-info = "pythonwrench.
|
|
46
|
-
pythonwrench-tree = "pythonwrench.
|
|
47
|
-
pythonwrench-safe-rmdir = "pythonwrench.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
pythonwrench-info = "pythonwrench.entrypoints.info:main_info"
|
|
46
|
+
pythonwrench-tree = "pythonwrench.entrypoints.tree:main_tree"
|
|
47
|
+
pythonwrench-safe-rmdir = "pythonwrench.entrypoints.safe_rmdir:main_safe_rmdir"
|
|
48
|
+
pw-info = "pythonwrench.entrypoints.info:main_info"
|
|
49
|
+
pw-tree = "pythonwrench.entrypoints.tree:main_tree"
|
|
50
|
+
pw-safe-rmdir = "pythonwrench.entrypoints.safe_rmdir:main_safe_rmdir"
|
|
51
|
+
pyw-info = "pythonwrench.entrypoints.info:main_info"
|
|
52
|
+
pyw-tree = "pythonwrench.entrypoints.tree:main_tree"
|
|
53
|
+
pyw-safe-rmdir = "pythonwrench.entrypoints.safe_rmdir:main_safe_rmdir"
|
|
51
54
|
|
|
52
55
|
[project.optional-dependencies]
|
|
53
|
-
dev = [
|
|
56
|
+
dev = [
|
|
57
|
+
"pandas>=2.0.3",
|
|
58
|
+
"coverage[toml]>=7.6.1",
|
|
59
|
+
"ruff>=0.12.0",
|
|
60
|
+
"sphinx<9.0.0",
|
|
61
|
+
"sphinx-immaterial>=0.11.14",
|
|
62
|
+
"flake8>=5.0.4",
|
|
63
|
+
"ipykernel>=6.29.5",
|
|
64
|
+
"ipython>=8.12.3",
|
|
65
|
+
"pre-commit>=3.5.0",
|
|
66
|
+
"pytest>=8.3.5",
|
|
67
|
+
"setuptools>=75.3.2",
|
|
68
|
+
"twine>=6.1.0",
|
|
69
|
+
]
|
|
54
70
|
lazy = [
|
|
55
|
-
"lazy-loader>=0.4",
|
|
71
|
+
"lazy-loader>=0.4,<0.5",
|
|
56
72
|
]
|
|
57
73
|
|
|
58
74
|
[build-system]
|
|
@@ -80,23 +96,9 @@ testpaths = ["tests"]
|
|
|
80
96
|
source = ["src"]
|
|
81
97
|
|
|
82
98
|
[tool.ruff.lint.extend-per-file-ignores]
|
|
99
|
+
# F401: module imported but unused
|
|
100
|
+
# F403: ‘from module import *’ used; unable to detect undefined names
|
|
83
101
|
"__init__.py" = ["F401", "F403"]
|
|
84
102
|
|
|
85
103
|
[tool.uv.sources]
|
|
86
104
|
pythonwrench = { workspace = true }
|
|
87
|
-
|
|
88
|
-
[dependency-groups]
|
|
89
|
-
dev = [
|
|
90
|
-
"coverage[toml]>=7.6.1",
|
|
91
|
-
"flake8",
|
|
92
|
-
"ipykernel",
|
|
93
|
-
"ipython",
|
|
94
|
-
"pre-commit",
|
|
95
|
-
"pytest",
|
|
96
|
-
"pythonwrench",
|
|
97
|
-
"ruff>=0.12.0",
|
|
98
|
-
"setuptools",
|
|
99
|
-
"sphinx<9.0.0",
|
|
100
|
-
"sphinx-immaterial>=0.11.14",
|
|
101
|
-
"twine",
|
|
102
|
-
]
|
|
@@ -9,7 +9,7 @@ __author_email__ = "labbeti.pub@gmail.com"
|
|
|
9
9
|
__license__ = "MIT"
|
|
10
10
|
__maintainer__ = "Étienne Labbé (Labbeti)"
|
|
11
11
|
__status__ = "Development"
|
|
12
|
-
__version__ = "0.
|
|
12
|
+
__version__ = "0.6.1"
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
from typing import TYPE_CHECKING
|
|
@@ -28,31 +28,32 @@ if TYPE_CHECKING or lazy is None:
|
|
|
28
28
|
from . import checksum as checksum
|
|
29
29
|
from . import collections as collections
|
|
30
30
|
from . import concurrent as concurrent
|
|
31
|
-
from . import csv as csv
|
|
32
31
|
from . import dataclasses as dataclasses
|
|
33
32
|
from . import datetime as datetime
|
|
34
33
|
from . import difflib as difflib
|
|
35
34
|
from . import disk_cache as disk_cache
|
|
36
|
-
from . import
|
|
35
|
+
from . import entrypoints as entrypoints
|
|
37
36
|
from . import enum as enum
|
|
38
37
|
from . import functools as functools
|
|
39
38
|
from . import hashlib as hashlib
|
|
40
39
|
from . import importlib as importlib
|
|
41
40
|
from . import inspect as inspect
|
|
42
|
-
from . import json as json
|
|
43
|
-
from . import jsonl as jsonl
|
|
44
41
|
from . import logging as logging
|
|
45
42
|
from . import math as math
|
|
46
43
|
from . import os as os
|
|
47
|
-
from . import pickle as pickle
|
|
48
44
|
from . import random as random
|
|
49
45
|
from . import re as re
|
|
50
46
|
from . import semver as semver
|
|
47
|
+
from . import serialization as serialization
|
|
48
|
+
from . import time as time
|
|
51
49
|
from . import warnings as warnings
|
|
52
50
|
|
|
53
51
|
# Global library imports
|
|
54
52
|
from .abc import Singleton
|
|
55
53
|
from .argparse import (
|
|
54
|
+
add_dataclass_fields_to_parser,
|
|
55
|
+
new_parser_from_dataclass,
|
|
56
|
+
parse_args_using_dataclass,
|
|
56
57
|
parse_to,
|
|
57
58
|
str_to_bool,
|
|
58
59
|
str_to_none,
|
|
@@ -65,6 +66,7 @@ if TYPE_CHECKING or lazy is None:
|
|
|
65
66
|
from .cast import as_builtin, register_as_builtin_fn
|
|
66
67
|
from .checksum import checksum_any, checksum_object, register_checksum_fn
|
|
67
68
|
from .collections import (
|
|
69
|
+
SizedGenerator,
|
|
68
70
|
all_eq,
|
|
69
71
|
all_ne,
|
|
70
72
|
contained,
|
|
@@ -86,6 +88,7 @@ if TYPE_CHECKING or lazy is None:
|
|
|
86
88
|
recursive_generator,
|
|
87
89
|
reduce_add,
|
|
88
90
|
reduce_and,
|
|
91
|
+
reduce_matmul,
|
|
89
92
|
reduce_mul,
|
|
90
93
|
reduce_or,
|
|
91
94
|
shuffled,
|
|
@@ -98,7 +101,6 @@ if TYPE_CHECKING or lazy is None:
|
|
|
98
101
|
union_lists,
|
|
99
102
|
unzip,
|
|
100
103
|
)
|
|
101
|
-
from .csv import dump_csv, dumps_csv, load_csv, loads_csv, read_csv, save_csv
|
|
102
104
|
from .dataclasses import get_defaults_values
|
|
103
105
|
from .datetime import get_now, get_now_iso8601
|
|
104
106
|
from .difflib import find_closest_in_list, sequence_matcher_ratio
|
|
@@ -114,7 +116,9 @@ if TYPE_CHECKING or lazy is None:
|
|
|
114
116
|
)
|
|
115
117
|
from .hashlib import hash_file
|
|
116
118
|
from .importlib import (
|
|
119
|
+
ModulePlaceholder,
|
|
117
120
|
Placeholder,
|
|
121
|
+
import_if_available,
|
|
118
122
|
is_available_package,
|
|
119
123
|
is_editable_package,
|
|
120
124
|
reload_editable_packages,
|
|
@@ -123,15 +127,6 @@ if TYPE_CHECKING or lazy is None:
|
|
|
123
127
|
search_submodules,
|
|
124
128
|
)
|
|
125
129
|
from .inspect import get_argnames, get_current_fn_name, get_fullname
|
|
126
|
-
from .json import dump_json, dumps_json, load_json, loads_json, read_json, save_json
|
|
127
|
-
from .jsonl import (
|
|
128
|
-
dump_jsonl,
|
|
129
|
-
dumps_jsonl,
|
|
130
|
-
load_jsonl,
|
|
131
|
-
loads_jsonl,
|
|
132
|
-
read_jsonl,
|
|
133
|
-
save_jsonl,
|
|
134
|
-
)
|
|
135
130
|
from .logging import (
|
|
136
131
|
VERBOSE_DEBUG,
|
|
137
132
|
VERBOSE_ERROR,
|
|
@@ -150,14 +145,6 @@ if TYPE_CHECKING or lazy is None:
|
|
|
150
145
|
)
|
|
151
146
|
from .math import argmax, argmin, argsort, clamp, clip
|
|
152
147
|
from .os import get_num_cpus_available, safe_rmdir, tree_iter
|
|
153
|
-
from .pickle import (
|
|
154
|
-
dump_pickle,
|
|
155
|
-
dumps_pickle,
|
|
156
|
-
load_pickle,
|
|
157
|
-
loads_pickle,
|
|
158
|
-
read_pickle,
|
|
159
|
-
save_pickle,
|
|
160
|
-
)
|
|
161
148
|
from .random import randstr
|
|
162
149
|
from .re import (
|
|
163
150
|
PatternLike,
|
|
@@ -170,10 +157,38 @@ if TYPE_CHECKING or lazy is None:
|
|
|
170
157
|
sort_with_patterns,
|
|
171
158
|
)
|
|
172
159
|
from .semver import Version
|
|
160
|
+
from .serialization import (
|
|
161
|
+
dump_csv,
|
|
162
|
+
dump_json,
|
|
163
|
+
dump_jsonl,
|
|
164
|
+
dump_pickle,
|
|
165
|
+
dumps_csv,
|
|
166
|
+
dumps_json,
|
|
167
|
+
dumps_jsonl,
|
|
168
|
+
dumps_pickle,
|
|
169
|
+
load_csv,
|
|
170
|
+
load_json,
|
|
171
|
+
load_jsonl,
|
|
172
|
+
load_pickle,
|
|
173
|
+
loads_csv,
|
|
174
|
+
loads_json,
|
|
175
|
+
loads_jsonl,
|
|
176
|
+
loads_pickle,
|
|
177
|
+
read_csv,
|
|
178
|
+
read_json,
|
|
179
|
+
read_jsonl,
|
|
180
|
+
read_pickle,
|
|
181
|
+
save_csv,
|
|
182
|
+
save_json,
|
|
183
|
+
save_jsonl,
|
|
184
|
+
save_pickle,
|
|
185
|
+
)
|
|
186
|
+
from .time import Ticker
|
|
173
187
|
from .typing import (
|
|
174
188
|
BuiltinCollection,
|
|
175
189
|
BuiltinNumber,
|
|
176
190
|
BuiltinScalar,
|
|
191
|
+
Dataclass,
|
|
177
192
|
DataclassInstance,
|
|
178
193
|
EllipsisType,
|
|
179
194
|
ListOrTuple,
|
|
@@ -229,31 +244,32 @@ else:
|
|
|
229
244
|
"checksum",
|
|
230
245
|
"collections",
|
|
231
246
|
"concurrent",
|
|
232
|
-
"csv",
|
|
233
247
|
"dataclasses",
|
|
234
248
|
"datetime",
|
|
235
249
|
"difflib",
|
|
236
250
|
"disk_cache",
|
|
237
|
-
"
|
|
251
|
+
"entrypoints",
|
|
238
252
|
"enum",
|
|
239
253
|
"functools",
|
|
240
254
|
"hashlib",
|
|
241
255
|
"importlib",
|
|
242
256
|
"inspect",
|
|
243
|
-
"json",
|
|
244
|
-
"jsonl",
|
|
245
257
|
"logging",
|
|
246
258
|
"math",
|
|
247
259
|
"os",
|
|
248
|
-
"pickle",
|
|
249
260
|
"random",
|
|
250
261
|
"re",
|
|
251
262
|
"semver",
|
|
263
|
+
"serialization",
|
|
264
|
+
"time",
|
|
252
265
|
"typing",
|
|
253
266
|
"warnings",
|
|
254
267
|
],
|
|
255
268
|
submod_attrs={
|
|
256
269
|
"argparse": [
|
|
270
|
+
"add_dataclass_fields_to_parser",
|
|
271
|
+
"new_parser_from_dataclass",
|
|
272
|
+
"parse_args_using_dataclass",
|
|
257
273
|
"parse_to",
|
|
258
274
|
"str_to_bool",
|
|
259
275
|
"str_to_none",
|
|
@@ -267,6 +283,7 @@ else:
|
|
|
267
283
|
"cast": ["as_builtin", "register_as_builtin_fn"],
|
|
268
284
|
"checksum": ["checksum_any", "checksum_object", "register_checksum_fn"],
|
|
269
285
|
"collections": [
|
|
286
|
+
"SizedGenerator",
|
|
270
287
|
"all_eq",
|
|
271
288
|
"all_ne",
|
|
272
289
|
"contained",
|
|
@@ -288,6 +305,7 @@ else:
|
|
|
288
305
|
"recursive_generator",
|
|
289
306
|
"reduce_add",
|
|
290
307
|
"reduce_and",
|
|
308
|
+
"reduce_matmul",
|
|
291
309
|
"reduce_mul",
|
|
292
310
|
"reduce_or",
|
|
293
311
|
"shuffled",
|
|
@@ -300,13 +318,31 @@ else:
|
|
|
300
318
|
"union_lists",
|
|
301
319
|
"unzip",
|
|
302
320
|
],
|
|
303
|
-
"
|
|
321
|
+
"serialization": [
|
|
304
322
|
"dump_csv",
|
|
323
|
+
"dump_json",
|
|
324
|
+
"dump_jsonl",
|
|
325
|
+
"dump_pickle",
|
|
305
326
|
"dumps_csv",
|
|
327
|
+
"dumps_json",
|
|
328
|
+
"dumps_jsonl",
|
|
329
|
+
"dumps_pickle",
|
|
306
330
|
"load_csv",
|
|
331
|
+
"load_json",
|
|
332
|
+
"load_jsonl",
|
|
333
|
+
"load_pickle",
|
|
307
334
|
"loads_csv",
|
|
335
|
+
"loads_json",
|
|
336
|
+
"loads_jsonl",
|
|
337
|
+
"loads_pickle",
|
|
308
338
|
"read_csv",
|
|
339
|
+
"read_json",
|
|
340
|
+
"read_jsonl",
|
|
341
|
+
"read_pickle",
|
|
309
342
|
"save_csv",
|
|
343
|
+
"save_json",
|
|
344
|
+
"save_jsonl",
|
|
345
|
+
"save_pickle",
|
|
310
346
|
],
|
|
311
347
|
"dataclasses": ["get_defaults_values"],
|
|
312
348
|
"datetime": ["get_now", "get_now_iso8601"],
|
|
@@ -323,6 +359,8 @@ else:
|
|
|
323
359
|
],
|
|
324
360
|
"hashlib": ["hash_file"],
|
|
325
361
|
"importlib": [
|
|
362
|
+
"import_if_available",
|
|
363
|
+
"ModulePlaceholder",
|
|
326
364
|
"is_available_package",
|
|
327
365
|
"is_editable_package",
|
|
328
366
|
"reload_editable_packages",
|
|
@@ -332,22 +370,6 @@ else:
|
|
|
332
370
|
"Placeholder",
|
|
333
371
|
],
|
|
334
372
|
"inspect": ["get_argnames", "get_current_fn_name", "get_fullname"],
|
|
335
|
-
"json": [
|
|
336
|
-
"dump_json",
|
|
337
|
-
"dumps_json",
|
|
338
|
-
"load_json",
|
|
339
|
-
"loads_json",
|
|
340
|
-
"read_json",
|
|
341
|
-
"save_json",
|
|
342
|
-
],
|
|
343
|
-
"jsonl": [
|
|
344
|
-
"dump_jsonl",
|
|
345
|
-
"dumps_jsonl",
|
|
346
|
-
"load_jsonl",
|
|
347
|
-
"loads_jsonl",
|
|
348
|
-
"read_jsonl",
|
|
349
|
-
"save_jsonl",
|
|
350
|
-
],
|
|
351
373
|
"logging": [
|
|
352
374
|
"VERBOSE_DEBUG",
|
|
353
375
|
"VERBOSE_ERROR",
|
|
@@ -366,14 +388,6 @@ else:
|
|
|
366
388
|
],
|
|
367
389
|
"math": ["argmax", "argmin", "argsort", "clamp", "clip"],
|
|
368
390
|
"os": ["get_num_cpus_available", "safe_rmdir", "tree_iter"],
|
|
369
|
-
"pickle": [
|
|
370
|
-
"dump_pickle",
|
|
371
|
-
"dumps_pickle",
|
|
372
|
-
"load_pickle",
|
|
373
|
-
"loads_pickle",
|
|
374
|
-
"read_pickle",
|
|
375
|
-
"save_pickle",
|
|
376
|
-
],
|
|
377
391
|
"random": ["randstr"],
|
|
378
392
|
"re": [
|
|
379
393
|
"PatternLike",
|
|
@@ -386,10 +400,12 @@ else:
|
|
|
386
400
|
"sort_with_patterns",
|
|
387
401
|
],
|
|
388
402
|
"semver": ["Version"],
|
|
403
|
+
"time": ["Ticker"],
|
|
389
404
|
"typing": [
|
|
390
405
|
"BuiltinCollection",
|
|
391
406
|
"BuiltinNumber",
|
|
392
407
|
"BuiltinScalar",
|
|
408
|
+
"Dataclass",
|
|
393
409
|
"DataclassInstance",
|
|
394
410
|
"EllipsisType",
|
|
395
411
|
"ListOrTuple",
|
|
@@ -443,4 +459,4 @@ else:
|
|
|
443
459
|
version = __version__
|
|
444
460
|
version_info = Version(__version__)
|
|
445
461
|
|
|
446
|
-
del
|
|
462
|
+
del TYPE_CHECKING, lazy
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
|
|
4
|
-
import os
|
|
5
4
|
from functools import wraps
|
|
6
|
-
from io import TextIOWrapper
|
|
7
|
-
from pathlib import Path
|
|
8
5
|
from typing import (
|
|
9
6
|
Any,
|
|
10
7
|
Callable,
|
|
@@ -16,7 +13,6 @@ from typing import (
|
|
|
16
13
|
Tuple,
|
|
17
14
|
Union,
|
|
18
15
|
get_args,
|
|
19
|
-
overload,
|
|
20
16
|
)
|
|
21
17
|
|
|
22
18
|
from typing_extensions import ParamSpec, TypeVar
|
|
@@ -43,10 +39,14 @@ def return_none(*args, **kwargs) -> None:
|
|
|
43
39
|
def _decorator_factory(
|
|
44
40
|
inner_fn: Optional[Callable[P, U]],
|
|
45
41
|
*,
|
|
46
|
-
pre_fn: Callable[..., Any] =
|
|
47
|
-
post_fn: Callable[..., Any] =
|
|
42
|
+
pre_fn: Optional[Callable[..., Any]] = None,
|
|
43
|
+
post_fn: Optional[Callable[..., Any]] = None,
|
|
48
44
|
) -> Callable[[Callable[P, U]], Callable[P, U]]:
|
|
49
45
|
"""Deprecated decorator for function aliases."""
|
|
46
|
+
if pre_fn is None:
|
|
47
|
+
pre_fn = return_none
|
|
48
|
+
if post_fn is None:
|
|
49
|
+
post_fn = return_none
|
|
50
50
|
|
|
51
51
|
def wrapper_factory(fn: Callable[P, U]) -> Callable[P, U]:
|
|
52
52
|
if inner_fn is None:
|
|
@@ -169,53 +169,3 @@ class _FunctionRegistry(Generic[T_Output]):
|
|
|
169
169
|
else:
|
|
170
170
|
msg = f"Invalid argument {unk_mode=}. (expected one of {get_args(UnkMode)})"
|
|
171
171
|
raise ValueError(msg)
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
@overload
|
|
175
|
-
def _setup_output_fpath(
|
|
176
|
-
fpath: Union[str, Path, os.PathLike],
|
|
177
|
-
overwrite: bool,
|
|
178
|
-
make_parents: bool,
|
|
179
|
-
absolute: bool = True,
|
|
180
|
-
) -> Path: ...
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
@overload
|
|
184
|
-
def _setup_output_fpath(
|
|
185
|
-
fpath: TextIOWrapper,
|
|
186
|
-
overwrite: bool,
|
|
187
|
-
make_parents: bool,
|
|
188
|
-
absolute: bool = True,
|
|
189
|
-
) -> TextIOWrapper: ...
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
@overload
|
|
193
|
-
def _setup_output_fpath(
|
|
194
|
-
fpath: None,
|
|
195
|
-
overwrite: bool,
|
|
196
|
-
make_parents: bool,
|
|
197
|
-
absolute: bool = True,
|
|
198
|
-
) -> None: ...
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
def _setup_output_fpath(
|
|
202
|
-
fpath: Union[str, Path, os.PathLike, TextIOWrapper, None],
|
|
203
|
-
overwrite: bool,
|
|
204
|
-
make_parents: bool,
|
|
205
|
-
absolute: bool = True,
|
|
206
|
-
) -> Union[Path, None, TextIOWrapper]:
|
|
207
|
-
"""Resolve path, expand path and create intermediate parents."""
|
|
208
|
-
if not isinstance(fpath, (str, Path, os.PathLike)):
|
|
209
|
-
return fpath
|
|
210
|
-
|
|
211
|
-
fpath = Path(fpath)
|
|
212
|
-
if absolute:
|
|
213
|
-
fpath = fpath.resolve().expanduser()
|
|
214
|
-
|
|
215
|
-
if not overwrite and fpath.exists():
|
|
216
|
-
msg = f"File {fpath} already exists."
|
|
217
|
-
raise FileExistsError(msg)
|
|
218
|
-
elif make_parents:
|
|
219
|
-
fpath.parent.mkdir(parents=True, exist_ok=True)
|
|
220
|
-
|
|
221
|
-
return fpath
|