diff --git a/doc/source/PrettyFormat.rst b/doc/source/PrettyFormat.rst index a39d7c7..8dc7adf 100644 --- a/doc/source/PrettyFormat.rst +++ b/doc/source/PrettyFormat.rst @@ -12,7 +12,7 @@ API: Helpers: `pretty_repr`, `pretty_str` and base class `PrettyFormat`. :param src: object to process :type src: typing.Union[ - six.binary_type, six.text_type, int, typing.Iterable, object + typing.AnyStr, int, typing.Iterable, object ] :param indent: start indentation, all next levels is +indent_step :type indent: int @@ -36,7 +36,7 @@ API: Helpers: `pretty_repr`, `pretty_str` and base class `PrettyFormat`. :param src: object to process :type src: typing.Union[ - six.binary_type, six.text_type, int, typing.Iterable, object + typing.AnyStr, int, typing.Iterable, object ] :param indent: start indentation, all next levels is +indent_step :type indent: int @@ -90,7 +90,7 @@ API: Helpers: `pretty_repr`, `pretty_str` and base class `PrettyFormat`. :param src: object to process :type src: typing.Union[ - six.binary_type, six.text_type, int, typing.Iterable, object + typing.AnyStr, int, typing.Iterable, object ] :param indent: start indentation :type indent: int @@ -98,7 +98,7 @@ API: Helpers: `pretty_repr`, `pretty_str` and base class `PrettyFormat`. do not indent open bracket and simple parameters :type no_indent_start: bool :return: formatted string - :rtype: six.text_type + :rtype: typing.Text .. py:method:: __call__(src, indent=0, no_indent_start=False) @@ -106,7 +106,7 @@ API: Helpers: `pretty_repr`, `pretty_str` and base class `PrettyFormat`. :param src: object to process :type src: typing.Union[ - six.binary_type, six.text_type, int, typing.Iterable, object + typing.AnyStr, int, typing.Iterable, object ] :param indent: start indentation :type indent: int diff --git a/doc/source/logwrap.rst b/doc/source/logwrap.rst index bebe72e..329d480 100644 --- a/doc/source/logwrap.rst +++ b/doc/source/logwrap.rst @@ -69,9 +69,9 @@ API: Decorators: `LogWrap` class and `logwrap` function. :param arg: bound parameter :type arg: BoundParameter :param arg_repr: repr for value - :type arg_repr: six.text_type + :type arg_repr: typing.Text :return: processed repr for value - :rtype: six.text_type + :rtype: typing.Text Override this method if some modifications required for result of repr() over parameter diff --git a/logwrap/_log_wrap2.py b/logwrap/_log_wrap2.py index 555c0f2..bb12316 100644 --- a/logwrap/_log_wrap2.py +++ b/logwrap/_log_wrap2.py @@ -96,18 +96,11 @@ def __init__( # pylint: disable=keyword-arg-before-vararg signature with decorated function, or arguments bind will be failed! :type spec: typing.Optional[typing.Callable] - :param blacklisted_names: Blacklisted argument names. - Arguments with this names will be skipped - in log. + :param blacklisted_names: Blacklisted argument names. Arguments with this names will be skipped in log. :type blacklisted_names: typing.Optional[typing.Iterable[str]] - :param blacklisted_exceptions: list of exception, - which should be re-raised without - producing log record. - :type blacklisted_exceptions: typing.Optional[ - typing.Iterable[Exception] - ] - :param log_call_args: log call arguments before executing - wrapped function. + :param blacklisted_exceptions: list of exception, which should be re-raised without producing log record. + :type blacklisted_exceptions: typing.Optional[typing.Iterable[Exception]] + :param log_call_args: log call arguments before executing wrapped function. :type log_call_args: bool :param log_call_args_on_exc: log call arguments if exception raised. :type log_call_args_on_exc: bool @@ -192,12 +185,9 @@ def logwrap( # pylint: disable=keyword-arg-before-vararg Note: this object should provide fully compatible signature with decorated function, or arguments bind will be failed! :type spec: typing.Optional[typing.Callable] - :param blacklisted_names: Blacklisted argument names. - Arguments with this names will be skipped in log. + :param blacklisted_names: Blacklisted argument names. Arguments with this names will be skipped in log. :type blacklisted_names: typing.Optional[typing.List[str]] - :param blacklisted_exceptions: list of exception, - which should be re-raised without - producing log record. + :param blacklisted_exceptions: list of exception, which should be re-raised without producing log record. :type blacklisted_exceptions: typing.Optional[typing.List[Exception]] :param log_call_args: log call arguments before executing wrapped function. :type log_call_args: bool diff --git a/logwrap/_log_wrap_shared.py b/logwrap/_log_wrap_shared.py index 0e076ed..0c95d9f 100644 --- a/logwrap/_log_wrap_shared.py +++ b/logwrap/_log_wrap_shared.py @@ -510,16 +510,16 @@ def pre_process_param( # pylint: disable=no-self-use def post_process_param( # pylint: disable=no-self-use,unused-argument self, arg, # type: BoundParameter - arg_repr # type: six.text_type - ): # type: (...) -> six.text_type + arg_repr # type: typing.Text + ): # type: (...) -> typing.Text """Process parameter for the future logging. :param arg: bound parameter :type arg: BoundParameter :param arg_repr: repr for value - :type arg_repr: six.text_type + :type arg_repr: typing.Text :return: processed repr for value - :rtype: six.text_type + :rtype: typing.Text Override this method if some modifications required for result of repr() over parameter @@ -532,13 +532,13 @@ def _get_func_args_repr( sig, # type: inspect.Signature args, # type: typing.Tuple kwargs # type: typing.Dict[str, typing.Any] - ): # type: (...) -> six.text_type + ): # type: (...) -> typing.Text """Internal helper for reducing complexity of decorator code. :type sig: inspect.Signature :type args: tuple :type kwargs: dict - :rtype: str + :rtype: typing.Text .. versionchanged:: 3.3.0 Use pre- and post- processing of params during execution """ diff --git a/logwrap/_log_wrap_shared.pyi b/logwrap/_log_wrap_shared.pyi index 37b2880..630f33e 100644 --- a/logwrap/_log_wrap_shared.pyi +++ b/logwrap/_log_wrap_shared.pyi @@ -146,15 +146,15 @@ class BaseLogWrap(_class_decorator.BaseDecorator): def post_process_param( self, arg: BoundParameter, - arg_repr: six.text_type - ) -> six.text_type: ... + arg_repr: typing.Text + ) -> typing.Text: ... def _get_func_args_repr( self, sig: inspect.Signature, args: typing.Tuple, kwargs: typing.Dict[str, typing.Any] - ) -> six.text_type: ... + ) -> typing.Text: ... def _make_done_record( self, diff --git a/logwrap/_repr_utils.py b/logwrap/_repr_utils.py index a9752aa..3683b06 100644 --- a/logwrap/_repr_utils.py +++ b/logwrap/_repr_utils.py @@ -1,4 +1,4 @@ -# Copyright 2016 Alexey Stepanov aka penguinolog +# Copyright 2018 Alexey Stepanov aka penguinolog # Copyright 2016 Mirantis, Inc. @@ -221,12 +221,12 @@ def _repr_callable( self, src, # type: typing.Union[types.FunctionType, types.MethodType] indent=0 # type: int - ): # type: (...) -> six.text_type + ): # type: (...) -> typing.Text """Repr callable object (function or method). :type src: typing.Union[types.FunctionType, types.MethodType] :type indent: int - :rtype: str + :rtype: typing.Text """ raise NotImplementedError() # pragma: no cover @@ -236,16 +236,16 @@ def _repr_simple( src, # type: typing.Any indent=0, # type: int no_indent_start=False # type: bool - ): # type: (...) -> six.text_type + ): # type: (...) -> typing.Text """Repr object without iteration. :type src: typing.Union[ - six.binary_type, six.text_type, int, typing.Iterable, + typing.AnyStr, int, typing.Iterable, object, ] :type indent: int :type no_indent_start: bool - :rtype: str + :rtype: typing.Text """ raise NotImplementedError() # pragma: no cover @@ -254,14 +254,14 @@ def _repr_dict_items( self, src, # type: typing.Dict indent=0 # type: int - ): # type: (...) -> typing.Iterator[str] + ): # type: (...) -> typing.Iterator[typing.Text] """Repr dict items. :param src: object to process :type src: typing.Dict :param indent: start indentation :type indent: int - :rtype: typing.Iterator[str] + :rtype: typing.Iterator[typing.Text] """ raise NotImplementedError() # pragma: no cover @@ -273,7 +273,7 @@ def _repr_iterable_item( indent, # type: int result, # type: str suffix, # type: str - ): # type: (...) -> six.text_type + ): # type: (...) -> typing.Text """Repr iterable item. :param nl: newline before item @@ -288,7 +288,7 @@ def _repr_iterable_item( :type result: str :param suffix: suffix :type suffix: str - :rtype: str + :rtype: typing.Text """ raise NotImplementedError() # pragma: no cover @@ -296,14 +296,14 @@ def _repr_iterable_items( self, src, # type: typing.Iterable indent=0 # type: int - ): # type: (...) -> typing.Iterator[str] + ): # type: (...) -> typing.Iterator[typing.Text] """Repr iterable items (not designed for dicts). :param src: object to process :type src: typing.Iterable :param indent: start indentation :type indent: int - :rtype: typing.Iterator[str] + :rtype: typing.Iterator[typing.Text] """ for elem in src: yield '\n' + self.process_element( @@ -313,10 +313,10 @@ def _repr_iterable_items( @property @abc.abstractmethod - def _magic_method_name(self): # type: () -> six.text_type + def _magic_method_name(self): # type: () -> typing.Text """Magic method name. - :rtype: str + :rtype: typing.Text """ raise NotImplementedError() # pragma: no cover @@ -325,12 +325,12 @@ def process_element( src, # type: typing.Any indent=0, # type: int no_indent_start=False # type: bool - ): # type: (...) -> six.text_type + ): # type: (...) -> typing.Text """Make human readable representation of object. :param src: object to process :type src: typing.Union[ - six.binary_type, six.text_type, int, typing.Iterable, object + typing.AnyStr, int, typing.Iterable, object ] :param indent: start indentation :type indent: int @@ -338,7 +338,7 @@ def process_element( do not indent open bracket and simple parameters :type no_indent_start: bool :return: formatted string - :rtype: six.text_type + :rtype: typing.Text """ if hasattr(src, self._magic_method_name): return getattr( @@ -395,7 +395,7 @@ def __call__( :param src: object to process :type src: typing.Union[ - six.binary_type, six.text_type, int, typing.Iterable, object + typing.AnyStr, int, typing.Iterable, object ] :param indent: start indentation :type indent: int @@ -427,18 +427,18 @@ class PrettyRepr(PrettyFormat): __slots__ = () @property - def _magic_method_name(self): # type: () -> six.text_type + def _magic_method_name(self): # type: () -> typing.Text """Magic method name. - :rtype: str + :rtype: typing.Text """ return '__pretty_repr__' @staticmethod def _strings_repr( indent, # type: int - val # type: typing.Union[six.binary_type, six.text_type] - ): # type: (...) -> six.text_type + val # type: typing.AnyStr + ): # type: (...) -> typing.Text """Custom repr for strings and binary strings.""" if isinstance(val, six.binary_type): val = val.decode( @@ -460,16 +460,16 @@ def _repr_simple( src, # type: typing.Any indent=0, # type: int no_indent_start=False # type: bool - ): # type: (...) -> six.text_type + ): # type: (...) -> typing.Text """Repr object without iteration. :type src: typing.Union[ - six.binary_type, six.text_type, int, typing.Iterable, + typing.AnyStr, int, typing.Iterable, object, ] :type indent: int :type no_indent_start: bool - :rtype: str + :rtype: typing.Text """ indent = 0 if no_indent_start else indent if isinstance(src, set): @@ -490,14 +490,14 @@ def _repr_dict_items( self, src, # type: typing.Dict indent=0 # type: int - ): # type: (...) -> typing.Iterator[str] + ): # type: (...) -> typing.Iterator[typing.Text] """Repr dict items. :param src: object to process :type src: dict :param indent: start indentation :type indent: int - :rtype: typing.Iterator[str] + :rtype: typing.Iterator[typing.Text] """ max_len = max((len(repr(key)) for key in src)) if src else 0 for key, val in src.items(): @@ -517,12 +517,12 @@ def _repr_callable( self, src, # type: typing.Union[types.FunctionType, types.MethodType] indent=0 # type: int - ): # type: (...) -> six.text_type + ): # type: (...) -> typing.Text """Repr callable object (function or method). :type src: typing.Union[types.FunctionType, types.MethodType] :type indent: int - :rtype: str + :rtype: typing.Text """ param_str = "" @@ -566,7 +566,7 @@ def _repr_iterable_item( indent, # type: int result, # type: str suffix, # type: str - ): # type: (...) -> six.text_type + ): # type: (...) -> typing.Text """Repr iterable item. :param nl: newline before item @@ -581,7 +581,7 @@ def _repr_iterable_item( :type result: str :param suffix: suffix :type suffix: str - :rtype: str + :rtype: typing.Text """ return ( "{nl}" @@ -607,18 +607,18 @@ class PrettyStr(PrettyFormat): __slots__ = () @property - def _magic_method_name(self): # type: () -> six.text_type + def _magic_method_name(self): # type: () -> typing.Text """Magic method name. - :rtype: str + :rtype: typing.Text """ return '__pretty_str__' @staticmethod def _strings_str( indent, # type: int - val # type: typing.Union[six.binary_type, six.text_type] - ): # type: (...) -> six.text_type + val # type: typing.AnyStr + ): # type: (...) -> typing.Text """Custom repr for strings and binary strings.""" if isinstance(val, six.binary_type): val = val.decode( @@ -636,16 +636,16 @@ def _repr_simple( src, # type: typing.Any indent=0, # type: int no_indent_start=False # type: bool - ): # type: (...) -> six.text_type + ): # type: (...) -> typing.Text """Repr object without iteration. :type src: typing.Union[ - six.binary_type, six.text_type, int, typing.Iterable, + typing.AnyStr, int, typing.Iterable, object, ] :type indent: int :type no_indent_start: bool - :rtype: str + :rtype: typing.Text """ indent = 0 if no_indent_start else indent if isinstance(src, set): @@ -666,14 +666,14 @@ def _repr_dict_items( self, src, # type: typing.Dict indent=0 # type: int - ): # type: (...) -> typing.Iterator[str] + ): # type: (...) -> typing.Iterator[typing.Text] """Repr dict items. :param src: object to process :type src: dict :param indent: start indentation :type indent: int - :rtype: typing.Generator[str] + :rtype: typing.Generator[typing.Text] """ max_len = max((len(str(key)) for key in src)) if src else 0 for key, val in src.items(): @@ -693,12 +693,12 @@ def _repr_callable( self, src, # type: typing.Union[types.FunctionType, types.MethodType] indent=0 # type: int - ): # type: (...) -> six.text_type + ): # type: (...) -> typing.Text """Repr callable object (function or method). :type src: typing.Union[types.FunctionType, types.MethodType] :type indent: int - :rtype: str + :rtype: typing.Text """ param_str = "" @@ -742,7 +742,7 @@ def _repr_iterable_item( indent, # type: int result, # type: str suffix, # type: str - ): # type: (...) -> six.text_type + ): # type: (...) -> typing.Text """Repr iterable item. :param nl: newline before item @@ -757,7 +757,7 @@ def _repr_iterable_item( :type result: str :param suffix: suffix :type suffix: str - :rtype: str + :rtype: typing.Text """ return ( "{nl}" @@ -785,7 +785,7 @@ def pretty_repr( :param src: object to process :type src: typing.Union[ - six.binary_type, six.text_type, int, typing.Iterable, object + typing.AnyStr, int, typing.Iterable, object ] :param indent: start indentation, all next levels is +indent_step :type indent: int @@ -823,7 +823,7 @@ def pretty_str( :param src: object to process :type src: typing.Union[ - six.binary_type, six.text_type, int, typing.Iterable, object + typing.AnyStr, int, typing.Iterable, object ] :param indent: start indentation, all next levels is +indent_step :type indent: int diff --git a/logwrap/_repr_utils.pyi b/logwrap/_repr_utils.pyi index 51bbe1d..6e1556c 100644 --- a/logwrap/_repr_utils.pyi +++ b/logwrap/_repr_utils.pyi @@ -25,7 +25,7 @@ class PrettyFormat: self, src: typing.Union[types.FunctionType, types.MethodType], indent: int=0 - ) -> six.text_type: ... + ) -> typing.Text: ... @abc.abstractmethod def _repr_simple( @@ -33,14 +33,14 @@ class PrettyFormat: src: typing.Any, indent: int=0, no_indent_start: bool=False - ) -> six.text_type: ... + ) -> typing.Text: ... @abc.abstractmethod def _repr_dict_items( self, src: typing.Dict, indent: int=0 - ) -> typing.Iterator[str]: ... + ) -> typing.Iterator[typing.Text]: ... @staticmethod def _repr_iterable_item( @@ -50,7 +50,7 @@ class PrettyFormat: indent: int, result: str, suffix: str, - ) -> six.text_type: ... + ) -> typing.Text: ... def _repr_iterable_items( self, @@ -60,40 +60,40 @@ class PrettyFormat: @property @abc.abstractmethod - def _magic_method_name(self) -> six.text_type: ... + def _magic_method_name(self) -> typing.Text: ... - def process_element(self, src: typing.Any, indent: int=..., no_indent_start: bool=...) -> six.text_type: ... + def process_element(self, src: typing.Any, indent: int=..., no_indent_start: bool=...) -> typing.Text: ... def __call__(self, src: typing.Any, indent: int=..., no_indent_start: bool=...) -> typing.Union[six.text_type, str]: ... class PrettyRepr(PrettyFormat): @property - def _magic_method_name(self) -> six.text_type: ... + def _magic_method_name(self) -> typing.Text: ... @staticmethod def _strings_repr( indent: int, - val: typing.Union[six.binary_type, six.text_type] - ) -> six.text_type: ... + val: typing.AnyStr + ) -> typing.Text: ... def _repr_simple( self, src: typing.Any, indent: int=0, no_indent_start: bool=False - ) -> six.text_type: ... + ) -> typing.Text: ... def _repr_dict_items( self, src: typing.Dict, indent: int=0 - ) -> typing.Iterator[str]: ... + ) -> typing.Iterator[typing.Text]: ... def _repr_callable( self, src: typing.Union[types.FunctionType, types.MethodType], indent: int=0 - ) -> six.text_type: ... + ) -> typing.Text: ... @staticmethod def _repr_iterable_item( @@ -103,36 +103,36 @@ class PrettyRepr(PrettyFormat): indent: int, result: str, suffix: str, - ) -> six.text_type: ... + ) -> typing.Text: ... class PrettyStr(PrettyFormat): @property - def _magic_method_name(self) -> six.text_type: ... + def _magic_method_name(self) -> typing.Text: ... @staticmethod def _strings_str( indent: int, - val: typing.Union[six.binary_type, six.text_type] - ) -> six.text_type: ... + val: typing.AnyStr + ) -> typing.Text: ... def _repr_simple( self, src: typing.Any, indent: int=0, no_indent_start: bool=False - ) -> six.text_type: ... + ) -> typing.Text: ... def _repr_dict_items( self, src: typing.Dict, indent: int=0 - ) -> typing.Iterator[str]: ... + ) -> typing.Iterator[typing.Text]: ... def _repr_callable( self, src: typing.Union[types.FunctionType, types.MethodType], indent: int=0 - ) -> six.text_type: ... + ) -> typing.Text: ... @staticmethod def _repr_iterable_item( @@ -142,7 +142,7 @@ class PrettyStr(PrettyFormat): indent: int, result: str, suffix: str, - ) -> six.text_type: ... + ) -> typing.Text: ... def pretty_repr( src: typing.Any,