Skip to content

Commit 3500c39

Browse files
committed
Fix kwargs modification
1 parent 2de128e commit 3500c39

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pytest_reportportal/rp_logging.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import threading
1919
from contextlib import contextmanager
2020
from functools import wraps
21+
from typing import Any
2122

2223
from reportportal_client import current, set_current
2324
from reportportal_client import RPLogger
@@ -116,23 +117,22 @@ def patching_logger_class():
116117
try:
117118
def wrap_log(original_func):
118119
@wraps(original_func)
119-
def _log(self, *args, **kwargs):
120-
attachment = kwargs.pop('attachment', None)
120+
def _log(self, *args: list[Any], **kwargs: dict[str, Any]):
121+
my_kwargs = kwargs.copy()
122+
attachment = my_kwargs.pop('attachment', None)
121123
if attachment is not None:
122-
kwargs.setdefault('extra', {}).update(
123-
{'attachment': attachment})
124+
my_kwargs.setdefault('extra', {}).update({'attachment': attachment})
125+
124126
# Python 3.11 start catches stack frames in wrappers,
125127
# so add additional stack level skip to not show it
126128
if sys.version_info >= (3, 11):
127-
my_kwargs = kwargs.copy()
128-
if 'stacklevel' in kwargs:
129+
if 'stacklevel' in my_kwargs:
129130
my_kwargs['stacklevel'] = my_kwargs['stacklevel'] + 1
130131
else:
131132
my_kwargs['stacklevel'] = 2
132133
return original_func(self, *args, **my_kwargs)
133134
else:
134-
return original_func(self, *args, **kwargs)
135-
135+
return original_func(self, *args, **my_kwargs)
136136
return _log
137137

138138
def wrap_makeRecord(original_func):

0 commit comments

Comments
 (0)