Skip to content

Commit

Permalink
use black code style (#45)
Browse files Browse the repository at this point in the history
* use black code style

Unify projects codestyle
  • Loading branch information
penguinolog committed Sep 21, 2018
1 parent 08930ab commit 2cd4a09
Show file tree
Hide file tree
Showing 9 changed files with 263 additions and 592 deletions.
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ logwrap
:target: https://pypi.python.org/pypi/logwrap
.. image:: https://img.shields.io/github/license/python-useful-helpers/logwrap.svg
:target: https://raw.githubusercontent.com/python-useful-helpers/logwrap/master/LICENSE

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/ambv/black

logwrap is a helper for logging in human-readable format function arguments and call result on function call.
Why? Because logging of `*args, **kwargs` become useless with project grow and you need more details in call log.
Expand Down
38 changes: 16 additions & 22 deletions logwrap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,29 @@
later it has been reworked and extended for support of special cases.
"""

from ._repr_utils import (
PrettyFormat,
PrettyRepr,
PrettyStr,
pretty_repr,
pretty_str
)
from ._repr_utils import PrettyFormat, PrettyRepr, PrettyStr, pretty_repr, pretty_str
from ._log_wrap import logwrap, LogWrap, BoundParameter, bind_args_kwargs

__all__ = (
'LogWrap',
'logwrap',
'PrettyFormat',
'PrettyRepr',
'PrettyStr',
'pretty_repr',
'pretty_str',
'BoundParameter',
'bind_args_kwargs'
"LogWrap",
"logwrap",
"PrettyFormat",
"PrettyRepr",
"PrettyStr",
"pretty_repr",
"pretty_str",
"BoundParameter",
"bind_args_kwargs",
)

__version__ = '4.9.0'
__version__ = "4.9.0"
__author__ = "Alexey Stepanov"
__author_email__ = 'penguinolog@gmail.com'
__author_email__ = "penguinolog@gmail.com"
__maintainers__ = {
'Alexey Stepanov': 'penguinolog@gmail.com',
'Antonio Esposito': 'esposito.cloud@gmail.com',
'Dennis Dmitriev': 'dis-xcom@gmail.com',
"Alexey Stepanov": "penguinolog@gmail.com",
"Antonio Esposito": "esposito.cloud@gmail.com",
"Dennis Dmitriev": "dis-xcom@gmail.com",
}
__url__ = 'https://github.com/python-useful-helpers/logwrap'
__url__ = "https://github.com/python-useful-helpers/logwrap"
__description__ = "Decorator for logging function arguments and return value by human-readable way"
__license__ = "Apache License, Version 2.0"
27 changes: 7 additions & 20 deletions logwrap/_class_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ class BaseDecorator(metaclass=abc.ABCMeta):
False
"""

def __init__(
self,
func: typing.Optional[typing.Callable] = None
) -> None:
def __init__(self, func: typing.Optional[typing.Callable] = None) -> None:
"""Decorator.
:param func: function to wrap
Expand All @@ -80,20 +77,15 @@ def __init__(
# pylint: enable=assigning-non-slot

@property
def _func(
self
) -> typing.Optional[typing.Callable]:
def _func(self) -> typing.Optional[typing.Callable]:
"""Get wrapped function.
:rtype: typing.Optional[typing.Callable]
"""
return self.__func # pragma: no cover

@abc.abstractmethod
def _get_function_wrapper(
self,
func: typing.Callable
) -> typing.Callable:
def _get_function_wrapper(self, func: typing.Callable) -> typing.Callable:
"""Here should be constructed and returned real decorator.
:param func: Wrapped function
Expand All @@ -102,11 +94,7 @@ def _get_function_wrapper(
"""
raise NotImplementedError() # pragma: no cover

def __call__(
self,
*args: typing.Union[typing.Callable, typing.Any],
**kwargs: typing.Any
) -> typing.Any:
def __call__(self, *args: typing.Union[typing.Callable, typing.Any], **kwargs: typing.Any) -> typing.Any:
"""Main decorator getter."""
l_args = list(args)

Expand All @@ -123,14 +111,13 @@ def __call__(
def __repr__(self) -> str:
"""For debug purposes."""
return "<{cls}({func!r}) at 0x{id:X}>".format(
cls=self.__class__.__name__,
func=self.__func,
id=id(self)
cls=self.__class__.__name__, func=self.__func, id=id(self)
) # pragma: no cover


# 8<----------------------------------------------------------------------------

if __name__ == '__main__':
if __name__ == "__main__":
import doctest # pragma: no cover

doctest.testmod(verbose=True) # pragma: no cover
Loading

0 comments on commit 2cd4a09

Please sign in to comment.