python-utils 3.9.0__tar.gz → 3.9.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.
- {python_utils-3.9.0/python_utils.egg-info → python_utils-3.9.1}/PKG-INFO +2 -2
- {python_utils-3.9.0 → python_utils-3.9.1}/_python_utils_tests/test_time.py +12 -12
- {python_utils-3.9.0 → python_utils-3.9.1}/pyproject.toml +1 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/python_utils/__about__.py +1 -1
- {python_utils-3.9.0 → python_utils-3.9.1}/python_utils/formatters.py +5 -5
- {python_utils-3.9.0 → python_utils-3.9.1/python_utils.egg-info}/PKG-INFO +2 -2
- {python_utils-3.9.0 → python_utils-3.9.1}/setup.py +1 -1
- {python_utils-3.9.0 → python_utils-3.9.1}/tox.ini +2 -1
- {python_utils-3.9.0 → python_utils-3.9.1}/LICENSE +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/MANIFEST.in +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/README.rst +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/_python_utils_tests/__init__.py +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/_python_utils_tests/requirements.txt +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/_python_utils_tests/test_aio.py +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/_python_utils_tests/test_containers.py +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/_python_utils_tests/test_decorators.py +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/_python_utils_tests/test_generators.py +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/_python_utils_tests/test_import.py +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/_python_utils_tests/test_logger.py +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/_python_utils_tests/test_python_utils.py +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/coverage.rc +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/pytest.ini +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/python_utils/__init__.py +30 -30
- {python_utils-3.9.0 → python_utils-3.9.1}/python_utils/aio.py +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/python_utils/containers.py +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/python_utils/converters.py +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/python_utils/decorators.py +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/python_utils/exceptions.py +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/python_utils/generators.py +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/python_utils/import_.py +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/python_utils/logger.py +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/python_utils/loguru.py +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/python_utils/py.typed +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/python_utils/terminal.py +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/python_utils/time.py +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/python_utils/types.py +84 -84
- {python_utils-3.9.0 → python_utils-3.9.1}/python_utils.egg-info/SOURCES.txt +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/python_utils.egg-info/dependency_links.txt +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/python_utils.egg-info/requires.txt +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/python_utils.egg-info/top_level.txt +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/requirements.txt +0 -0
- {python_utils-3.9.0 → python_utils-3.9.1}/setup.cfg +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-utils
|
|
3
|
-
Version: 3.9.
|
|
3
|
+
Version: 3.9.1
|
|
4
4
|
Summary: Python Utils is a module with some convenient utilities not included with the standard Python install
|
|
5
5
|
Home-page: https://github.com/WoLpH/python-utils
|
|
6
6
|
Author: Rick van Hattem
|
|
7
7
|
Author-email: Wolph@wol.ph
|
|
8
8
|
License: BSD
|
|
9
9
|
Classifier: License :: OSI Approved :: BSD License
|
|
10
|
-
Requires-Python:
|
|
10
|
+
Requires-Python: >=3.9.0
|
|
11
11
|
License-File: LICENSE
|
|
12
12
|
Requires-Dist: typing_extensions>3.10.0.2
|
|
13
13
|
Provides-Extra: loguru
|
|
@@ -45,15 +45,15 @@ async def test_aio_timeout_generator(
|
|
|
45
45
|
@pytest.mark.parametrize(
|
|
46
46
|
'timeout,interval,interval_multiplier,maximum_interval,iterable,result',
|
|
47
47
|
[
|
|
48
|
-
(0.
|
|
49
|
-
(0.
|
|
50
|
-
(0.
|
|
51
|
-
(0.
|
|
48
|
+
(0.1, 0.06, 0.5, 0.1, 'abc', 'c'),
|
|
49
|
+
(0.1, 0.07, 0.5, 0.1, itertools.count, 2),
|
|
50
|
+
(0.1, 0.07, 0.5, 0.1, itertools.count(), 2),
|
|
51
|
+
(0.1, 0.06, 1.0, None, 'abc', 'c'),
|
|
52
52
|
(
|
|
53
|
-
timedelta(seconds=0.
|
|
54
|
-
timedelta(seconds=0.
|
|
53
|
+
timedelta(seconds=0.1),
|
|
54
|
+
timedelta(seconds=0.06),
|
|
55
55
|
2.0,
|
|
56
|
-
timedelta(seconds=0.
|
|
56
|
+
timedelta(seconds=0.1),
|
|
57
57
|
itertools.count,
|
|
58
58
|
2,
|
|
59
59
|
),
|
|
@@ -91,28 +91,28 @@ async def test_aio_generator_timeout_detector() -> None:
|
|
|
91
91
|
|
|
92
92
|
async def generator() -> types.AsyncGenerator[int, None]:
|
|
93
93
|
for i in range(10):
|
|
94
|
-
await asyncio.sleep(i /
|
|
94
|
+
await asyncio.sleep(i / 20.0)
|
|
95
95
|
yield i
|
|
96
96
|
|
|
97
97
|
detector = python_utils.aio_generator_timeout_detector
|
|
98
98
|
# Test regular timeout with reraise
|
|
99
99
|
with pytest.raises(asyncio.TimeoutError):
|
|
100
|
-
async for i in detector(generator(), 0.
|
|
100
|
+
async for i in detector(generator(), 0.25):
|
|
101
101
|
pass
|
|
102
102
|
|
|
103
103
|
# Test regular timeout with clean exit
|
|
104
|
-
async for i in detector(generator(), 0.
|
|
104
|
+
async for i in detector(generator(), 0.25, on_timeout=None):
|
|
105
105
|
pass
|
|
106
106
|
|
|
107
107
|
assert i == 4
|
|
108
108
|
|
|
109
109
|
# Test total timeout with reraise
|
|
110
110
|
with pytest.raises(asyncio.TimeoutError):
|
|
111
|
-
async for i in detector(generator(), total_timeout=0.
|
|
111
|
+
async for i in detector(generator(), total_timeout=0.5):
|
|
112
112
|
pass
|
|
113
113
|
|
|
114
114
|
# Test total timeout with clean exit
|
|
115
|
-
async for i in detector(generator(), total_timeout=0.
|
|
115
|
+
async for i in detector(generator(), total_timeout=0.5, on_timeout=None):
|
|
116
116
|
pass
|
|
117
117
|
|
|
118
118
|
assert i == 4
|
|
@@ -161,11 +161,11 @@ def timesince(
|
|
|
161
161
|
|
|
162
162
|
output: types.List[str] = []
|
|
163
163
|
for period, singular, plural in periods:
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
164
|
+
int_period = int(period)
|
|
165
|
+
if int_period == 1:
|
|
166
|
+
output.append(f'{int_period} {singular}')
|
|
167
|
+
elif int_period:
|
|
168
|
+
output.append(f'{int_period} {plural}')
|
|
169
169
|
|
|
170
170
|
if output:
|
|
171
171
|
return f'{" and ".join(output[:2])} ago'
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-utils
|
|
3
|
-
Version: 3.9.
|
|
3
|
+
Version: 3.9.1
|
|
4
4
|
Summary: Python Utils is a module with some convenient utilities not included with the standard Python install
|
|
5
5
|
Home-page: https://github.com/WoLpH/python-utils
|
|
6
6
|
Author: Rick van Hattem
|
|
7
7
|
Author-email: Wolph@wol.ph
|
|
8
8
|
License: BSD
|
|
9
9
|
Classifier: License :: OSI Approved :: BSD License
|
|
10
|
-
Requires-Python:
|
|
10
|
+
Requires-Python: >=3.9.0
|
|
11
11
|
License-File: LICENSE
|
|
12
12
|
Requires-Dist: typing_extensions>3.10.0.2
|
|
13
13
|
Provides-Extra: loguru
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[tox]
|
|
2
|
-
envlist = ruff, black, py39, py310, py311, py312, py313, docs, mypy, pyright
|
|
2
|
+
envlist = ruff, black, pypy3, py39, py310, py311, py312, py313, docs, mypy, pyright
|
|
3
3
|
skip_missing_interpreters = True
|
|
4
4
|
|
|
5
5
|
[testenv]
|
|
@@ -9,6 +9,7 @@ basepython =
|
|
|
9
9
|
py311: python3.11
|
|
10
10
|
py312: python3.12
|
|
11
11
|
py313: python3.13
|
|
12
|
+
pypy3: pypy3
|
|
12
13
|
|
|
13
14
|
setenv = PY_IGNORE_IMPORTMISMATCH=1
|
|
14
15
|
deps =
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -83,44 +83,44 @@ from .time import (
|
|
|
83
83
|
)
|
|
84
84
|
|
|
85
85
|
__all__ = [
|
|
86
|
+
'CastedDict',
|
|
87
|
+
'LazyCastedDict',
|
|
88
|
+
'Logged',
|
|
89
|
+
'LoggerBase',
|
|
90
|
+
'UniqueList',
|
|
91
|
+
'abatcher',
|
|
92
|
+
'acount',
|
|
86
93
|
'aio',
|
|
87
|
-
'
|
|
94
|
+
'aio_generator_timeout_detector',
|
|
95
|
+
'aio_generator_timeout_detector_decorator',
|
|
96
|
+
'aio_timeout_generator',
|
|
97
|
+
'batcher',
|
|
98
|
+
'camel_to_underscore',
|
|
88
99
|
'converters',
|
|
89
100
|
'decorators',
|
|
101
|
+
'delta_to_seconds',
|
|
102
|
+
'delta_to_seconds_or_none',
|
|
103
|
+
'format_time',
|
|
90
104
|
'formatters',
|
|
105
|
+
'generators',
|
|
106
|
+
'get_terminal_size',
|
|
91
107
|
'import_',
|
|
108
|
+
'import_global',
|
|
109
|
+
'listify',
|
|
92
110
|
'logger',
|
|
93
|
-
'
|
|
94
|
-
'time',
|
|
95
|
-
'types',
|
|
96
|
-
'to_int',
|
|
97
|
-
'to_float',
|
|
98
|
-
'to_unicode',
|
|
99
|
-
'to_str',
|
|
100
|
-
'scale_1024',
|
|
111
|
+
'raise_exception',
|
|
101
112
|
'remap',
|
|
113
|
+
'reraise',
|
|
114
|
+
'scale_1024',
|
|
102
115
|
'set_attributes',
|
|
103
|
-
'
|
|
104
|
-
'
|
|
105
|
-
'timesince',
|
|
106
|
-
'import_global',
|
|
107
|
-
'get_terminal_size',
|
|
116
|
+
'terminal',
|
|
117
|
+
'time',
|
|
108
118
|
'timedelta_to_seconds',
|
|
109
|
-
'format_time',
|
|
110
119
|
'timeout_generator',
|
|
111
|
-
'
|
|
112
|
-
'
|
|
113
|
-
'
|
|
114
|
-
'
|
|
115
|
-
'
|
|
116
|
-
'
|
|
117
|
-
'delta_to_seconds',
|
|
118
|
-
'delta_to_seconds_or_none',
|
|
119
|
-
'reraise',
|
|
120
|
-
'raise_exception',
|
|
121
|
-
'Logged',
|
|
122
|
-
'LoggerBase',
|
|
123
|
-
'CastedDict',
|
|
124
|
-
'LazyCastedDict',
|
|
125
|
-
'UniqueList',
|
|
120
|
+
'timesince',
|
|
121
|
+
'to_float',
|
|
122
|
+
'to_int',
|
|
123
|
+
'to_str',
|
|
124
|
+
'to_unicode',
|
|
125
|
+
'types',
|
|
126
126
|
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -54,128 +54,128 @@ timestamp_type = U[
|
|
|
54
54
|
]
|
|
55
55
|
|
|
56
56
|
__all__ = [
|
|
57
|
-
'
|
|
58
|
-
'
|
|
59
|
-
|
|
60
|
-
'
|
|
61
|
-
'timestamp_type',
|
|
57
|
+
'IO',
|
|
58
|
+
'TYPE_CHECKING',
|
|
59
|
+
# ABCs (from collections.abc).
|
|
60
|
+
'AbstractSet',
|
|
62
61
|
# The types from the typing module.
|
|
63
62
|
# Super-special typing primitives.
|
|
64
63
|
'Annotated',
|
|
65
64
|
'Any',
|
|
65
|
+
# One-off things.
|
|
66
|
+
'AnyStr',
|
|
67
|
+
'AsyncContextManager',
|
|
68
|
+
'AsyncGenerator',
|
|
69
|
+
'AsyncGeneratorType',
|
|
70
|
+
'AsyncIterable',
|
|
71
|
+
'AsyncIterator',
|
|
72
|
+
'Awaitable',
|
|
73
|
+
# Other concrete types.
|
|
74
|
+
'BinaryIO',
|
|
75
|
+
'BuiltinFunctionType',
|
|
76
|
+
'BuiltinMethodType',
|
|
77
|
+
'ByteString',
|
|
66
78
|
'Callable',
|
|
79
|
+
# Concrete collection types.
|
|
80
|
+
'ChainMap',
|
|
81
|
+
'ClassMethodDescriptorType',
|
|
67
82
|
'ClassVar',
|
|
83
|
+
'CodeType',
|
|
84
|
+
'Collection',
|
|
68
85
|
'Concatenate',
|
|
86
|
+
'Container',
|
|
87
|
+
'ContextManager',
|
|
88
|
+
'Coroutine',
|
|
89
|
+
'CoroutineType',
|
|
90
|
+
'Counter',
|
|
91
|
+
'DecimalNumber',
|
|
92
|
+
'DefaultDict',
|
|
93
|
+
'Deque',
|
|
94
|
+
'Dict',
|
|
95
|
+
'DynamicClassAttribute',
|
|
69
96
|
'Final',
|
|
70
97
|
'ForwardRef',
|
|
98
|
+
'FrameType',
|
|
99
|
+
'FrozenSet',
|
|
100
|
+
# Types from the `types` module.
|
|
101
|
+
'FunctionType',
|
|
102
|
+
'Generator',
|
|
103
|
+
'GeneratorType',
|
|
71
104
|
'Generic',
|
|
72
|
-
'
|
|
73
|
-
'SupportsIndex',
|
|
74
|
-
'Optional',
|
|
75
|
-
'ParamSpec',
|
|
76
|
-
'ParamSpecArgs',
|
|
77
|
-
'ParamSpecKwargs',
|
|
78
|
-
'Protocol',
|
|
79
|
-
'Tuple',
|
|
80
|
-
'Type',
|
|
81
|
-
'TypeVar',
|
|
82
|
-
'Union',
|
|
83
|
-
# ABCs (from collections.abc).
|
|
84
|
-
'AbstractSet',
|
|
85
|
-
'ByteString',
|
|
86
|
-
'Container',
|
|
87
|
-
'ContextManager',
|
|
105
|
+
'GetSetDescriptorType',
|
|
88
106
|
'Hashable',
|
|
89
107
|
'ItemsView',
|
|
90
108
|
'Iterable',
|
|
91
109
|
'Iterator',
|
|
92
110
|
'KeysView',
|
|
111
|
+
'LambdaType',
|
|
112
|
+
'List',
|
|
113
|
+
'Literal',
|
|
93
114
|
'Mapping',
|
|
115
|
+
'MappingProxyType',
|
|
94
116
|
'MappingView',
|
|
117
|
+
'Match',
|
|
118
|
+
'MemberDescriptorType',
|
|
119
|
+
'MethodDescriptorType',
|
|
120
|
+
'MethodType',
|
|
121
|
+
'MethodWrapperType',
|
|
122
|
+
'ModuleType',
|
|
95
123
|
'MutableMapping',
|
|
96
124
|
'MutableSequence',
|
|
97
125
|
'MutableSet',
|
|
98
|
-
'
|
|
99
|
-
'
|
|
100
|
-
'
|
|
101
|
-
'
|
|
102
|
-
'
|
|
103
|
-
'
|
|
104
|
-
'
|
|
105
|
-
'
|
|
106
|
-
'
|
|
107
|
-
'
|
|
126
|
+
'NamedTuple', # Not really a type.
|
|
127
|
+
'NewType',
|
|
128
|
+
'NoReturn',
|
|
129
|
+
'Number',
|
|
130
|
+
'Optional',
|
|
131
|
+
'OptionalScope',
|
|
132
|
+
'OrderedDict',
|
|
133
|
+
'ParamSpec',
|
|
134
|
+
'ParamSpecArgs',
|
|
135
|
+
'ParamSpecKwargs',
|
|
136
|
+
'Pattern',
|
|
137
|
+
'Protocol',
|
|
108
138
|
# Structural checks, a.k.a. protocols.
|
|
109
139
|
'Reversible',
|
|
140
|
+
'Sequence',
|
|
141
|
+
'Set',
|
|
142
|
+
'SimpleNamespace',
|
|
143
|
+
'Sized',
|
|
110
144
|
'SupportsAbs',
|
|
111
145
|
'SupportsBytes',
|
|
112
146
|
'SupportsComplex',
|
|
113
147
|
'SupportsFloat',
|
|
114
148
|
'SupportsIndex',
|
|
149
|
+
'SupportsIndex',
|
|
115
150
|
'SupportsInt',
|
|
116
151
|
'SupportsRound',
|
|
117
|
-
|
|
118
|
-
'ChainMap',
|
|
119
|
-
'Counter',
|
|
120
|
-
'Deque',
|
|
121
|
-
'Dict',
|
|
122
|
-
'DefaultDict',
|
|
123
|
-
'List',
|
|
124
|
-
'OrderedDict',
|
|
125
|
-
'Set',
|
|
126
|
-
'FrozenSet',
|
|
127
|
-
'NamedTuple', # Not really a type.
|
|
128
|
-
'TypedDict', # Not really a type.
|
|
129
|
-
'Generator',
|
|
130
|
-
# Other concrete types.
|
|
131
|
-
'BinaryIO',
|
|
132
|
-
'IO',
|
|
133
|
-
'Match',
|
|
134
|
-
'Pattern',
|
|
152
|
+
'Text',
|
|
135
153
|
'TextIO',
|
|
136
|
-
|
|
137
|
-
'
|
|
154
|
+
'TracebackType',
|
|
155
|
+
'TracebackType',
|
|
156
|
+
'Tuple',
|
|
157
|
+
'Type',
|
|
158
|
+
'TypeAlias',
|
|
159
|
+
'TypeGuard',
|
|
160
|
+
'TypeVar',
|
|
161
|
+
'TypedDict', # Not really a type.
|
|
162
|
+
'Union',
|
|
163
|
+
'ValuesView',
|
|
164
|
+
'WrapperDescriptorType',
|
|
138
165
|
'cast',
|
|
166
|
+
'coroutine',
|
|
167
|
+
'delta_type',
|
|
139
168
|
'final',
|
|
140
169
|
'get_args',
|
|
141
170
|
'get_origin',
|
|
142
171
|
'get_type_hints',
|
|
143
172
|
'is_typeddict',
|
|
144
|
-
'
|
|
173
|
+
'new_class',
|
|
145
174
|
'no_type_check',
|
|
146
175
|
'no_type_check_decorator',
|
|
147
|
-
'NoReturn',
|
|
148
176
|
'overload',
|
|
149
|
-
'runtime_checkable',
|
|
150
|
-
'Text',
|
|
151
|
-
'TYPE_CHECKING',
|
|
152
|
-
'TypeAlias',
|
|
153
|
-
'TypeGuard',
|
|
154
|
-
'TracebackType',
|
|
155
|
-
# Types from the `types` module.
|
|
156
|
-
'FunctionType',
|
|
157
|
-
'LambdaType',
|
|
158
|
-
'CodeType',
|
|
159
|
-
'MappingProxyType',
|
|
160
|
-
'SimpleNamespace',
|
|
161
|
-
'GeneratorType',
|
|
162
|
-
'CoroutineType',
|
|
163
|
-
'AsyncGeneratorType',
|
|
164
|
-
'MethodType',
|
|
165
|
-
'BuiltinFunctionType',
|
|
166
|
-
'BuiltinMethodType',
|
|
167
|
-
'WrapperDescriptorType',
|
|
168
|
-
'MethodWrapperType',
|
|
169
|
-
'MethodDescriptorType',
|
|
170
|
-
'ClassMethodDescriptorType',
|
|
171
|
-
'ModuleType',
|
|
172
|
-
'TracebackType',
|
|
173
|
-
'FrameType',
|
|
174
|
-
'GetSetDescriptorType',
|
|
175
|
-
'MemberDescriptorType',
|
|
176
|
-
'new_class',
|
|
177
|
-
'resolve_bases',
|
|
178
177
|
'prepare_class',
|
|
179
|
-
'
|
|
180
|
-
'
|
|
178
|
+
'resolve_bases',
|
|
179
|
+
'runtime_checkable',
|
|
180
|
+
'timestamp_type',
|
|
181
181
|
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|