Skip to content

Commit dbfcb6a

Browse files
committed
Merge branch 'release/3.6.0'
2 parents bfe4693 + e68d6e4 commit dbfcb6a

File tree

23 files changed

+328
-177
lines changed

23 files changed

+328
-177
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
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.7', '3.8', '3.9', '3.10', '3.11-dev']
14+
python-version: ['3.8', '3.9', '3.10', '3.11']
1515

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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
/docs/_build
55
/cover
66
/.eggs
7+
/.*

README.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ Links
2525
- Documentation: https://python-utils.readthedocs.io/en/latest/
2626
- My blog: https://wol.ph/
2727

28+
Security contact information
29+
------------------------------------------------------------------------------
30+
31+
To report a security vulnerability, please use the
32+
`Tidelift security contact <https://tidelift.com/security>`_.
33+
Tidelift will coordinate the fix and disclosure.
34+
2835
Requirements for installing:
2936
------------------------------------------------------------------------------
3037

_python_utils_tests/test_aio.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from datetime import datetime
2+
import pytest
3+
import asyncio
4+
5+
from python_utils import types
6+
from python_utils.aio import acount
7+
8+
9+
@pytest.mark.asyncio
10+
async def test_acount(monkeypatch: pytest.MonkeyPatch):
11+
sleeps: types.List[float] = []
12+
13+
async def mock_sleep(delay: float):
14+
sleeps.append(delay)
15+
16+
monkeypatch.setattr(asyncio, 'sleep', mock_sleep)
17+
18+
async for i in acount(delay=1, stop=3.5):
19+
print('i', i, datetime.now())
20+
21+
assert len(sleeps) == 4
22+
assert sum(sleeps) == 4

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from datetime import date
1414
import os
1515
import sys
16+
1617
sys.path.insert(0, os.path.abspath('..'))
1718

1819
from python_utils import __about__
@@ -63,4 +64,3 @@
6364
# html_static_path = ['_static']
6465

6566
intersphinx_mapping = {'python': ('https://docs.python.org/3', None)}
66-

pyproject.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[tool.black]
2+
line-length = 79
3+
target-version = ['py37', 'py38', 'py39', 'py310', 'py311']
4+
skip-string-normalization = true
5+
6+
[tool.pyright]
7+
include = ['python_utils']
8+
strict = ['python_utils', '_python_utils_tests/test_aio.py']
9+
# The terminal file is very OS specific and dependent on imports so we're skipping it from type checking
10+
ignore = ['python_utils/terminal.py']
11+
pythonVersion = '3.8'

pyrightconfig.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ addopts =
77
--doctest-modules
88
--cov python_utils
99
--cov-report term-missing
10-
--mypy
10+
; --mypy
1111

1212
doctest_optionflags =
1313
ALLOW_UNICODE

python_utils/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
)
88
__url__: str = 'https://github.com/WoLpH/python-utils'
99
# Omit type info due to automatic versioning script
10-
__version__ = '3.5.2'
10+
__version__ = '3.6.0'

python_utils/aio.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@
77

88
from . import types
99

10+
_N = types.TypeVar('_N', int, float)
11+
1012

1113
async def acount(
12-
start: float = 0,
13-
step: float = 1,
14+
start: _N = 0,
15+
step: _N = 1,
1416
delay: float = 0,
15-
stop: types.Optional[float] = None,
16-
) -> types.AsyncIterator[float]:
17+
stop: types.Optional[_N] = None,
18+
) -> types.AsyncIterator[_N]:
1719
'''Asyncio version of itertools.count()'''
1820
for item in itertools.count(start, step): # pragma: no branch
1921
if stop is not None and item >= stop:
2022
break
2123

22-
yield item
24+
yield types.cast(_N, item)
2325
await asyncio.sleep(delay)

0 commit comments

Comments
 (0)