Skip to content

Commit

Permalink
Fix kwargs modification
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Nov 22, 2024
1 parent 2de128e commit 3500c39
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pytest_reportportal/rp_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import threading
from contextlib import contextmanager
from functools import wraps
from typing import Any

from reportportal_client import current, set_current
from reportportal_client import RPLogger
Expand Down Expand Up @@ -116,23 +117,22 @@ def patching_logger_class():
try:
def wrap_log(original_func):
@wraps(original_func)
def _log(self, *args, **kwargs):
attachment = kwargs.pop('attachment', None)
def _log(self, *args: list[Any], **kwargs: dict[str, Any]):
my_kwargs = kwargs.copy()
attachment = my_kwargs.pop('attachment', None)
if attachment is not None:
kwargs.setdefault('extra', {}).update(
{'attachment': attachment})
my_kwargs.setdefault('extra', {}).update({'attachment': attachment})

# Python 3.11 start catches stack frames in wrappers,
# so add additional stack level skip to not show it
if sys.version_info >= (3, 11):
my_kwargs = kwargs.copy()
if 'stacklevel' in kwargs:
if 'stacklevel' in my_kwargs:
my_kwargs['stacklevel'] = my_kwargs['stacklevel'] + 1
else:
my_kwargs['stacklevel'] = 2
return original_func(self, *args, **my_kwargs)
else:
return original_func(self, *args, **kwargs)

return original_func(self, *args, **my_kwargs)
return _log

def wrap_makeRecord(original_func):
Expand Down

0 comments on commit 3500c39

Please sign in to comment.