Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 76 additions & 24 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,104 @@
sudo: false
language: python
os: linux
python:
- &mainstream_python 2.7
- &pypy pypy
install:
- &upgrade_python_toolset pip install --upgrade pip setuptools wheel
- pip install tox-travis
- pip install coveralls
script: tox
- pip install --upgrade pytest pytest-sugar
- &install_deps pip install -r CI_REQUIREMENTS.txt
- pip install --upgrade pytest-cov coveralls

_python:
- &python27
name: "Python 2.7"
python: 2.7
- &pypy
name: "PyPy"
python: pypy
- &python37
name: "Python 3.7"
python: 3.7
dist: xenial
sudo: true

_helpers:
- &build_package python setup.py bdist_wheel

- &static_analysis
stage: Static analysis
<<: *python27
after_success: skip

- &code_style_check
stage: Code style check
<<: *python27
after_success: skip

script:
- pip install -e .
- py.test -vv --cov-config .coveragerc --cov-report= --cov=logwrap test
- coverage report -m --fail-under 87
after_success:
- coveralls

jobs:
fast_finish: true
include:
- stage: Static analisys
python: 3.6
services: []
- stage: test
<<: *python27
- stage: test
<<: *pypy

- <<: *static_analysis
name: "PyLint"
install:
- *upgrade_python_toolset
- *install_deps
- pip install --upgrade "pylint < 2.0"
script:
- pylint logwrap
- <<: *static_analysis
name: "Bandit"
install:
- *upgrade_python_toolset
- pip install tox
- pip install --upgrade bandit
script:
- tox -e pylint,bandit,mypy
after_success: skip
- bandit -r logwrap
- <<: *static_analysis
<<: *python37
name: "MyPy"
install:
- *upgrade_python_toolset
- *install_deps
- pip install --upgrade "mypy >= 0.620"
script:
- mypy --strict logwrap

- stage: Code style check
python: *mainstream_python
services: []
- <<: *code_style_check
name: "PEP8"
install:
- *upgrade_python_toolset
- pip install tox
- pip install --upgrade flake8
script:
- tox -e pep8,pep257
after_success: skip
- flake8
- <<: *code_style_check
name: "PEP257"
install:
- *upgrade_python_toolset
- pip install --upgrade pydocstyle
script:
- pydocstyle logwrap

- stage: deploy
# This prevents job from appearing in test plan unless commit is tagged:
if: tag IS present
python: *pypy
services:
- docker
services: []
install:
- *upgrade_python_toolset
script: []
before_deploy:
- pip install -r build_requirements.txt
- python setup.py bdist_wheel
- *install_deps
script:
- *build_package
before_deploy: []
deploy:
- provider: pypi
# `skip_cleanup: true` is required to preserve binary wheels, built
Expand Down
16 changes: 4 additions & 12 deletions doc/source/PrettyFormat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ API: Helpers: `pretty_repr`, `pretty_str` and base class `PrettyFormat`.
Make human readable repr of object.

:param src: object to process
:type src: typing.Union[
typing.AnyStr, int, typing.Iterable, object
]
:type src: typing.Any
:param indent: start indentation, all next levels is +indent_step
:type indent: int
:param no_indent_start: do not indent open bracket and simple parameters
Expand All @@ -35,9 +33,7 @@ API: Helpers: `pretty_repr`, `pretty_str` and base class `PrettyFormat`.
.. versionadded:: 1.1.0

:param src: object to process
:type src: typing.Union[
typing.AnyStr, int, typing.Iterable, object
]
:type src: typing.Any
:param indent: start indentation, all next levels is +indent_step
:type indent: int
:param no_indent_start: do not indent open bracket and simple parameters
Expand Down Expand Up @@ -89,9 +85,7 @@ API: Helpers: `pretty_repr`, `pretty_str` and base class `PrettyFormat`.
Make human readable representation of object.

:param src: object to process
:type src: typing.Union[
typing.AnyStr, int, typing.Iterable, object
]
:type src: typing.Any
:param indent: start indentation
:type indent: int
:param no_indent_start:
Expand All @@ -105,9 +99,7 @@ API: Helpers: `pretty_repr`, `pretty_str` and base class `PrettyFormat`.
Make human readable representation of object. The main entry point.

:param src: object to process
:type src: typing.Union[
typing.AnyStr, int, typing.Iterable, object
]
:type src: typing.Any
:param indent: start indentation
:type indent: int
:param no_indent_start:
Expand Down
28 changes: 24 additions & 4 deletions logwrap/_log_wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,11 @@ def bind_args_kwargs(
"""Bind *args and **kwargs to signature and get Bound Parameters.

:param sig: source signature
:type sig: Signature
:type sig: inspect.Signature
:param args: not keyworded arguments
:type args: typing.Any
:param kwargs: keyworded arguments
:type kwargs: typing.Any
:return: Iterator for bound parameters with all information about it
:rtype: typing.Iterator[BoundParameter]

Expand Down Expand Up @@ -288,7 +292,9 @@ def log_level(self): # type: () -> int
def log_level(self, val): # type: (int) -> None
"""Log level for normal behavior.

:param val: log level to use for calls and returns
:type val: int
:raises TypeError: log level is not integer
"""
if not isinstance(val, int):
raise TypeError(
Expand All @@ -311,7 +317,9 @@ def exc_level(self): # type: () -> int
def exc_level(self, val): # type: (int) -> None
"""Log level for exceptions.

:param val: log level to use for captured exceptions
:type val: int
:raises TypeError: log level is not integer
"""
if not isinstance(val, int):
raise TypeError(
Expand All @@ -334,7 +342,9 @@ def max_indent(self): # type: () -> int
def max_indent(self, val): # type: (int) -> None
"""Maximum indentation.

:param val: Maximal indentation before use of simple repr()
:type val: int
:raises TypeError: indent is not integer
"""
if not isinstance(val, int):
raise TypeError(
Expand Down Expand Up @@ -373,7 +383,9 @@ def log_call_args(self): # type: () -> bool
def log_call_args(self, val): # type: (bool) -> None
"""Flag: log call arguments before call.

:param val: Enable flag
:type val: bool
:raises TypeError: Value is not bool
"""
if not isinstance(val, bool):
raise TypeError(
Expand All @@ -396,7 +408,9 @@ def log_call_args_on_exc(self): # type: () -> bool
def log_call_args_on_exc(self, val): # type: (bool) -> None
"""Flag: log call arguments on exception.

:param val: Enable flag
:type val: bool
:raises TypeError: Value is not bool
"""
if not isinstance(val, bool):
raise TypeError(
Expand All @@ -419,7 +433,9 @@ def log_result_obj(self): # type: () -> bool
def log_result_obj(self, val): # type: (bool) -> None
"""Flag: log result object.

:param val: Enable flag
:type val: bool
:raises TypeError: Value is not bool
"""
if not isinstance(val, bool):
raise TypeError(
Expand All @@ -432,7 +448,7 @@ def log_result_obj(self, val): # type: (bool) -> None

@property
def _logger(self): # type: () -> logging.Logger
"""logger instance.
"""Logger instance.

:rtype: logging.Logger
"""
Expand Down Expand Up @@ -513,9 +529,13 @@ def _get_func_args_repr(
): # type: (...) -> typing.Text
"""Internal helper for reducing complexity of decorator code.

:param sig: function signature
:type sig: inspect.Signature
:type args: tuple
:type kwargs: dict
:param args: not keyworded arguments
:type args: typing.Tuple
:param kwargs: keyworded arguments
:type kwargs: typing.Dict[str, typing.Any]
:return: repr over function arguments
:rtype: typing.Text

.. versionchanged:: 3.3.0 Use pre- and post- processing of params during execution
Expand Down
Loading