Skip to content

Commit 798bfa2

Browse files
committed
Merge branch 'release/3.9.1'
2 parents 68c9703 + 0a76c1c commit 798bfa2

File tree

10 files changed

+148
-139
lines changed

10 files changed

+148
-139
lines changed

.github/workflows/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
timeout-minutes: 4
1212
strategy:
1313
matrix:
14-
python-version: ['3.9', '3.10', '3.11', '3.12'] # Maybe soon?, '3.13']
14+
python-version: ['pypy3.9', 'pypy3.10', '3.9', '3.10', '3.11', '3.12'] # Maybe soon?, '3.13']
1515

1616
steps:
1717
- uses: actions/checkout@v4

_python_utils_tests/test_time.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ async def test_aio_timeout_generator(
4545
@pytest.mark.parametrize(
4646
'timeout,interval,interval_multiplier,maximum_interval,iterable,result',
4747
[
48-
(0.01, 0.006, 0.5, 0.01, 'abc', 'c'),
49-
(0.01, 0.007, 0.5, 0.01, itertools.count, 2),
50-
(0.01, 0.007, 0.5, 0.01, itertools.count(), 2),
51-
(0.01, 0.006, 1.0, None, 'abc', 'c'),
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'),
5252
(
53-
timedelta(seconds=0.01),
54-
timedelta(seconds=0.006),
53+
timedelta(seconds=0.1),
54+
timedelta(seconds=0.06),
5555
2.0,
56-
timedelta(seconds=0.01),
56+
timedelta(seconds=0.1),
5757
itertools.count,
5858
2,
5959
),
@@ -91,28 +91,28 @@ async def test_aio_generator_timeout_detector() -> None:
9191

9292
async def generator() -> types.AsyncGenerator[int, None]:
9393
for i in range(10):
94-
await asyncio.sleep(i / 100.0)
94+
await asyncio.sleep(i / 20.0)
9595
yield i
9696

9797
detector = python_utils.aio_generator_timeout_detector
9898
# Test regular timeout with reraise
9999
with pytest.raises(asyncio.TimeoutError):
100-
async for i in detector(generator(), 0.05):
100+
async for i in detector(generator(), 0.25):
101101
pass
102102

103103
# Test regular timeout with clean exit
104-
async for i in detector(generator(), 0.05, on_timeout=None):
104+
async for i in detector(generator(), 0.25, on_timeout=None):
105105
pass
106106

107107
assert i == 4
108108

109109
# Test total timeout with reraise
110110
with pytest.raises(asyncio.TimeoutError):
111-
async for i in detector(generator(), total_timeout=0.1):
111+
async for i in detector(generator(), total_timeout=0.5):
112112
pass
113113

114114
# Test total timeout with clean exit
115-
async for i in detector(generator(), total_timeout=0.1, on_timeout=None):
115+
async for i in detector(generator(), total_timeout=0.5, on_timeout=None):
116116
pass
117117

118118
assert i == 4

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pythonVersion = '3.9'
1414
[tool.mypy]
1515
strict = true
1616
check_untyped_defs = true
17+
files = ['python_utils', '_python_utils_tests', 'setup.py']
1718

1819
[[tool.mypy.overrides]]
1920
module = '_python_utils_tests.*'

python_utils/__about__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
)
2020
__url__: str = 'https://github.com/WoLpH/python-utils'
2121
# Omit type info due to automatic versioning script
22-
__version__ = '3.9.0'
22+
__version__ = '3.9.1'

python_utils/__init__.py

+30-30
Original file line numberDiff line numberDiff line change
@@ -83,44 +83,44 @@
8383
)
8484

8585
__all__ = [
86+
'CastedDict',
87+
'LazyCastedDict',
88+
'Logged',
89+
'LoggerBase',
90+
'UniqueList',
91+
'abatcher',
92+
'acount',
8693
'aio',
87-
'generators',
94+
'aio_generator_timeout_detector',
95+
'aio_generator_timeout_detector_decorator',
96+
'aio_timeout_generator',
97+
'batcher',
98+
'camel_to_underscore',
8899
'converters',
89100
'decorators',
101+
'delta_to_seconds',
102+
'delta_to_seconds_or_none',
103+
'format_time',
90104
'formatters',
105+
'generators',
106+
'get_terminal_size',
91107
'import_',
108+
'import_global',
109+
'listify',
92110
'logger',
93-
'terminal',
94-
'time',
95-
'types',
96-
'to_int',
97-
'to_float',
98-
'to_unicode',
99-
'to_str',
100-
'scale_1024',
111+
'raise_exception',
101112
'remap',
113+
'reraise',
114+
'scale_1024',
102115
'set_attributes',
103-
'listify',
104-
'camel_to_underscore',
105-
'timesince',
106-
'import_global',
107-
'get_terminal_size',
116+
'terminal',
117+
'time',
108118
'timedelta_to_seconds',
109-
'format_time',
110119
'timeout_generator',
111-
'acount',
112-
'abatcher',
113-
'batcher',
114-
'aio_timeout_generator',
115-
'aio_generator_timeout_detector_decorator',
116-
'aio_generator_timeout_detector',
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',
126126
]

python_utils/formatters.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,11 @@ def timesince(
161161

162162
output: types.List[str] = []
163163
for period, singular, plural in periods:
164-
if int(period):
165-
if int(period) == 1:
166-
output.append('%d %s' % (period, singular))
167-
else:
168-
output.append('%d %s' % (period, plural))
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}')
169169

170170
if output:
171171
return f'{" and ".join(output[:2])} ago'

python_utils/types.py

+84-84
Original file line numberDiff line numberDiff line change
@@ -54,128 +54,128 @@
5454
]
5555

5656
__all__ = [
57-
'OptionalScope',
58-
'Number',
59-
'DecimalNumber',
60-
'delta_type',
61-
'timestamp_type',
57+
'IO',
58+
'TYPE_CHECKING',
59+
# ABCs (from collections.abc).
60+
'AbstractSet',
6261
# The types from the typing module.
6362
# Super-special typing primitives.
6463
'Annotated',
6564
'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',
6678
'Callable',
79+
# Concrete collection types.
80+
'ChainMap',
81+
'ClassMethodDescriptorType',
6782
'ClassVar',
83+
'CodeType',
84+
'Collection',
6885
'Concatenate',
86+
'Container',
87+
'ContextManager',
88+
'Coroutine',
89+
'CoroutineType',
90+
'Counter',
91+
'DecimalNumber',
92+
'DefaultDict',
93+
'Deque',
94+
'Dict',
95+
'DynamicClassAttribute',
6996
'Final',
7097
'ForwardRef',
98+
'FrameType',
99+
'FrozenSet',
100+
# Types from the `types` module.
101+
'FunctionType',
102+
'Generator',
103+
'GeneratorType',
71104
'Generic',
72-
'Literal',
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',
88106
'Hashable',
89107
'ItemsView',
90108
'Iterable',
91109
'Iterator',
92110
'KeysView',
111+
'LambdaType',
112+
'List',
113+
'Literal',
93114
'Mapping',
115+
'MappingProxyType',
94116
'MappingView',
117+
'Match',
118+
'MemberDescriptorType',
119+
'MethodDescriptorType',
120+
'MethodType',
121+
'MethodWrapperType',
122+
'ModuleType',
95123
'MutableMapping',
96124
'MutableSequence',
97125
'MutableSet',
98-
'Sequence',
99-
'Sized',
100-
'ValuesView',
101-
'Awaitable',
102-
'AsyncIterator',
103-
'AsyncIterable',
104-
'Coroutine',
105-
'Collection',
106-
'AsyncGenerator',
107-
'AsyncContextManager',
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',
108138
# Structural checks, a.k.a. protocols.
109139
'Reversible',
140+
'Sequence',
141+
'Set',
142+
'SimpleNamespace',
143+
'Sized',
110144
'SupportsAbs',
111145
'SupportsBytes',
112146
'SupportsComplex',
113147
'SupportsFloat',
114148
'SupportsIndex',
149+
'SupportsIndex',
115150
'SupportsInt',
116151
'SupportsRound',
117-
# Concrete collection types.
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',
135153
'TextIO',
136-
# One-off things.
137-
'AnyStr',
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',
138165
'cast',
166+
'coroutine',
167+
'delta_type',
139168
'final',
140169
'get_args',
141170
'get_origin',
142171
'get_type_hints',
143172
'is_typeddict',
144-
'NewType',
173+
'new_class',
145174
'no_type_check',
146175
'no_type_check_decorator',
147-
'NoReturn',
148176
'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',
178177
'prepare_class',
179-
'DynamicClassAttribute',
180-
'coroutine',
178+
'resolve_bases',
179+
'runtime_checkable',
180+
'timestamp_type',
181181
]

0 commit comments

Comments
 (0)