Skip to content

Commit 4144951

Browse files
committed
Merge branch 'release/3.2.0'
2 parents e79d45d + 6be881d commit 4144951

File tree

15 files changed

+163
-103
lines changed

15 files changed

+163
-103
lines changed

.coveragerc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ exclude_lines =
2121
raise NotImplementedError
2222
if 0:
2323
if __name__ == .__main__.:
24+
if typing.TYPE_CHECKING:

.travis.yml

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

README.rst

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Useful Python Utils
22
==============================================================================
33

4-
.. image:: https://travis-ci.org/WoLpH/python-utils.svg?branch=master
5-
:target: https://travis-ci.org/WoLpH/python-utils
4+
.. image:: https://github.com/WoLpH/python-utils/actions/workflows/main.yml/badge.svg?branch=master
5+
:target: https://github.com/WoLpH/python-utils/actions/workflows/main.yml
66

77
.. image:: https://coveralls.io/repos/WoLpH/python-utils/badge.svg?branch=master
88
:target: https://coveralls.io/r/WoLpH/python-utils?branch=master
@@ -36,16 +36,22 @@ Installation:
3636

3737
The package can be installed through `pip` (this is the recommended method):
3838

39+
.. code-block:: bash
40+
3941
pip install python-utils
4042
4143
Or if `pip` is not available, `easy_install` should work as well:
4244

45+
.. code-block:: bash
46+
4347
easy_install python-utils
4448
4549
Or download the latest release from Pypi (https://pypi.python.org/pypi/python-utils) or Github.
4650

4751
Note that the releases on Pypi are signed with my GPG key (https://pgp.mit.edu/pks/lookup?op=vindex&search=0xE81444E9CE1F695D) and can be checked using GPG:
4852

53+
.. code-block:: bash
54+
4955
gpg --verify python-utils-<version>.tar.gz.asc python-utils-<version>.tar.gz
5056
5157
Quickstart
@@ -226,6 +232,22 @@ Or add a correclty named logger to your classes which can be easily accessed:
226232
import logging
227233
my_class.log(logging.ERROR, 'log')
228234
235+
Alternatively loguru is also supported. It is largely a drop-in replacement for the logging module which is a bit more convenient to configure:
236+
237+
First install the extra loguru package:
238+
239+
.. code-block:: bash
240+
241+
pip install 'python-utils[loguru]'
242+
243+
.. code-block:: python
244+
245+
class MyClass(Logurud):
246+
...
247+
248+
Now you can use the `Logurud` class to make functions such as `self.info()`
249+
available. The benefit of this approach is that you can add extra context or
250+
options to you specific loguru instance (i.e. `self.logger`):
229251

230252
Convenient type aliases and some commonly used types:
231253

_python_utils_tests/test_logger.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import pytest
2+
3+
from python_utils.loguru import Logurud
4+
5+
6+
loguru = pytest.importorskip('loguru')
7+
8+
9+
def test_logurud():
10+
class MyClass(Logurud):
11+
pass
12+
13+
my_class = MyClass()
14+
my_class.debug('debug')
15+
my_class.info('info')
16+
my_class.warning('warning')
17+
my_class.error('error')
18+
my_class.exception('exception')
19+
my_class.log(0, 'log')

docs/conf.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,7 @@
6060
# Add any paths that contain custom static files (such as style sheets) here,
6161
# relative to this directory. They are copied after the builtin static files,
6262
# so a file named "default.css" will overwrite the builtin "default.css".
63-
html_static_path = ['_static']
63+
# html_static_path = ['_static']
64+
65+
intersphinx_mapping = {'python': ('https://docs.python.org/3', None)}
66+

pytest.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ flake8-ignore =
1717
doctest_optionflags =
1818
ALLOW_UNICODE
1919
ALLOW_BYTES
20+
21+
asyncio_mode = strict

python_utils/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
'with the standard Python install')
77
__url__: str = 'https://github.com/WoLpH/python-utils'
88
# Omit type info due to automatic versioning script
9-
__version__ = '3.1.0'
9+
__version__ = '3.2.0'

python_utils/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from .time import timedelta_to_seconds
2727
from .time import timeout_generator
2828
from .time import aio_timeout_generator
29+
from .logger import Logged, LoggerBase
2930

3031
__all__ = [
3132
'aio',
@@ -55,4 +56,6 @@
5556
'timeout_generator',
5657
'acount',
5758
'aio_timeout_generator',
59+
'Logged',
60+
'LoggerBase',
5861
]

python_utils/containers.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
from __future__ import annotations
22

33
import abc
4-
from typing import Any
5-
from typing import Generator
4+
import typing
5+
from typing import Any, Generator
66

77
from . import types
88

9+
if typing.TYPE_CHECKING:
10+
import _typeshed # noqa: F401
11+
912
KT = types.TypeVar('KT')
1013
VT = types.TypeVar('VT')
1114
DT = types.Dict[KT, VT]
@@ -16,6 +19,7 @@
1619
DictUpdateArgs = types.Union[
1720
types.Mapping,
1821
types.Iterable[types.Union[types.Tuple[Any, Any], types.Mapping]],
22+
'_typeshed.SupportsKeysAndGetItem[KT, VT]',
1923
]
2024

2125

@@ -37,7 +41,7 @@ def __init__(
3741
def update(
3842
self,
3943
*args: DictUpdateArgs,
40-
**kwargs
44+
**kwargs: VT
4145
) -> None:
4246
if args:
4347
kwargs.update(*args)

python_utils/converters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def to_unicode(
181181
'''Convert objects to unicode, if needed decodes string with the given
182182
encoding and errors settings.
183183
184-
:rtype: unicode
184+
:rtype: str
185185
186186
>>> to_unicode(b'a')
187187
'a'

0 commit comments

Comments
 (0)