Skip to content

Commit 872f867

Browse files
authored
Merge pull request #266 from reportportal/develop
Release
2 parents 1659187 + b1552fd commit 872f867

28 files changed

Lines changed: 847 additions & 296 deletions

.pre-commit-config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# See https://pre-commit.com for more information
22
# See https://pre-commit.com/hooks.html for more hooks
3+
default_language_version:
4+
python: python3.10
35
repos:
46
- repo: https://github.com/pre-commit/pre-commit-hooks
57
rev: v5.0.0

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@
22

33
## [Unreleased]
44
### Added
5+
- Attribute key length and number truncation, by @HardNorth
6+
- Binary character replacement in basic text fields, by @HardNorth
7+
8+
## [5.7.0]
9+
### Added
510
- Official `Python 3.14` support, by @HardNorth
611
- Custom log level support in `RPLogHandler` class, by @HardNorth
712
### Removed
8-
- `Python 3.7` support, by @HardNorth
13+
- `Python 3.8` support, by @HardNorth
914
- Deprecated `log_manager.py` module, by @HardNorth
1015

1116
## [5.6.7]

reportportal_client/__init__.py

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ class _ClientOptions(TypedDict, total=False):
6262
launch_uuid_print: bool
6363
print_output: OutputType
6464
truncate_attributes: bool
65+
truncate_fields: bool
66+
replace_binary_chars: bool
67+
launch_name_length_limit: int
68+
item_name_length_limit: int
69+
launch_description_length_limit: int
70+
item_description_length_limit: int
6571
log_batch_size: int
6672
log_batch_payload_limit: int
6773
# Async client specific parameters
@@ -80,42 +86,48 @@ def create_client(
8086
) -> Optional[RP]:
8187
"""Create and ReportPortal Client based on the type and arguments provided.
8288
83-
:param client_type: Type of the Client to create.
84-
:param endpoint: Endpoint of the ReportPortal service.
85-
:param project: Project name to report to.
86-
:param api_key: Authorization API key.
87-
:param oauth_uri: OAuth 2.0 token endpoint URI (for OAuth authentication).
88-
:param oauth_username: Username for OAuth 2.0 authentication.
89-
:param oauth_password: Password for OAuth 2.0 authentication.
90-
:param oauth_client_id: OAuth 2.0 client ID.
91-
:param oauth_client_secret: OAuth 2.0 client secret (optional).
92-
:param oauth_scope: OAuth 2.0 scope (optional).
93-
:param launch_uuid: A launch UUID to use instead of starting own one.
94-
:param is_skipped_an_issue: Option to mark skipped tests as not 'To Investigate' items on the server
95-
side.
96-
:param verify_ssl: Option to skip ssl verification.
97-
:param retries: Number of retry attempts to make in case of connection / server
98-
errors.
99-
:param max_pool_size: Option to set the maximum number of connections to save the pool.
100-
:param http_timeout : A float in seconds for connect and read timeout. Use a Tuple to
101-
specific connect and read separately.
102-
:param mode: Launch mode, all Launches started by the client will be in that mode.
103-
:param launch_uuid_print: Print Launch UUID into passed TextIO or by default to stdout.
104-
:param print_output: Set output stream for Launch UUID printing.
105-
:param truncate_attributes: Truncate test item attributes to default maximum length.
106-
:param log_batch_size: Option to set the maximum number of logs that can be processed in one
107-
batch.
108-
:param log_batch_payload_limit: Maximum size in bytes of logs that can be processed in one batch.
109-
:param keepalive_timeout: For Async Clients only. Maximum amount of idle time in seconds before
110-
force connection closing.
111-
:param task_timeout: For Async Threaded and Batched Clients only. Time limit in seconds for a
112-
Task processing.
113-
:param shutdown_timeout: For Async Threaded and Batched Clients only. Time limit in seconds for
114-
shutting down internal Tasks.
115-
:param trigger_num: For Async Batched Client only. Number of tasks which triggers Task batch
116-
execution.
117-
:param trigger_interval: For Async Batched Client only. Time limit which triggers Task batch
118-
execution.
89+
:param client_type: Type of the Client to create.
90+
:param endpoint: Endpoint of the ReportPortal service.
91+
:param project: Project name to report to.
92+
:param api_key: Authorization API key.
93+
:param oauth_uri: OAuth 2.0 token endpoint URI (for OAuth authentication).
94+
:param oauth_username: Username for OAuth 2.0 authentication.
95+
:param oauth_password: Password for OAuth 2.0 authentication.
96+
:param oauth_client_id: OAuth 2.0 client ID.
97+
:param oauth_client_secret: OAuth 2.0 client secret (optional).
98+
:param oauth_scope: OAuth 2.0 scope (optional).
99+
:param launch_uuid: A launch UUID to use instead of starting own one.
100+
:param is_skipped_an_issue: Option to mark skipped tests as not 'To Investigate' items on the server
101+
side.
102+
:param verify_ssl: Option to skip ssl verification.
103+
:param retries: Number of retry attempts to make in case of connection / server
104+
errors.
105+
:param max_pool_size: Option to set the maximum number of connections to save the pool.
106+
:param http_timeout: A float in seconds for connect and read timeout. Use a Tuple to
107+
specific connect and read separately.
108+
:param mode: Launch mode, all Launches started by the client will be in that mode.
109+
:param launch_uuid_print: Print Launch UUID into passed TextIO or by default to stdout.
110+
:param print_output: Set output stream for Launch UUID printing.
111+
:param truncate_attributes: Truncate test item attributes to default maximum length.
112+
:param truncate_fields: Truncate request fields to configured limits.
113+
:param replace_binary_chars: Toggle replacement of basic binary characters with \ufffd char.
114+
:param launch_name_length_limit: Maximum allowed launch name length.
115+
:param item_name_length_limit: Maximum allowed test item name length.
116+
:param launch_description_length_limit: Maximum allowed launch description length.
117+
:param item_description_length_limit: Maximum allowed test item description length.
118+
:param log_batch_size: Option to set the maximum number of logs that can be processed in one
119+
batch.
120+
:param log_batch_payload_limit: Maximum size in bytes of logs that can be processed in one batch.
121+
:param keepalive_timeout: For Async Clients only. Maximum amount of idle time in seconds before
122+
force connection closing.
123+
:param task_timeout: For Async Threaded and Batched Clients only. Time limit in seconds for a
124+
Task processing.
125+
:param shutdown_timeout: For Async Threaded and Batched Clients only. Time limit in seconds for
126+
shutting down internal Tasks.
127+
:param trigger_num: For Async Batched Client only. Number of tasks which triggers Task batch
128+
execution.
129+
:param trigger_interval: For Async Batched Client only. Time limit which triggers Task batch
130+
execution.
119131
:return: ReportPortal Client instance.
120132
"""
121133
my_kwargs = kwargs.copy()

reportportal_client/_internal/aio/tasks.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,25 @@
1717
import sys
1818
import time
1919
from asyncio import Future
20-
from typing import Any, Awaitable, Coroutine, Generator, Generic, Optional, TypeVar, Union
20+
from typing import Any, Coroutine, Generator, Generic, Optional, TypeVar, Union
2121

2222
from reportportal_client.aio.tasks import BlockingOperationError, Task
2323

24+
if sys.version_info >= (3, 10):
25+
from typing import TypeAlias
26+
else:
27+
from typing_extensions import TypeAlias
28+
2429
_T = TypeVar("_T")
2530

2631
DEFAULT_TASK_TRIGGER_NUM: int = 10
2732
DEFAULT_TASK_TRIGGER_INTERVAL: float = 1.0
2833

34+
if sys.version_info >= (3, 12):
35+
_TaskCompatibleCoro: TypeAlias = Coroutine[Any, Any, Any]
36+
else:
37+
_TaskCompatibleCoro: TypeAlias = Union[Generator[Optional[Future[object]], None, Any], Coroutine[Any, Any, Any]]
38+
2939

3040
class BatchedTask(Generic[_T], Task[_T]):
3141
"""Represents a Task which uses the current Thread to execute itself."""
@@ -34,7 +44,7 @@ class BatchedTask(Generic[_T], Task[_T]):
3444

3545
def __init__(
3646
self,
37-
coro: Union[Generator[Future, None, _T], Awaitable[_T]],
47+
coro: _TaskCompatibleCoro,
3848
*,
3949
loop: asyncio.AbstractEventLoop,
4050
name: Optional[str] = None,
@@ -68,7 +78,7 @@ class ThreadedTask(Generic[_T], Task[_T]):
6878

6979
def __init__(
7080
self,
71-
coro: Union[Generator[Future, None, _T], Awaitable[_T]],
81+
coro: _TaskCompatibleCoro,
7282
wait_timeout: float,
7383
*,
7484
loop: asyncio.AbstractEventLoop,

reportportal_client/_internal/logs/batcher.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222

2323
logger = logging.getLogger(__name__)
2424

25-
T_co = TypeVar("T_co", bound="RPRequestLog", covariant=True)
25+
LogRequestType = TypeVar("LogRequestType", bound=RPRequestLog)
2626

2727

28-
class LogBatcher(Generic[T_co]):
28+
class LogBatcher(Generic[LogRequestType]):
2929
"""Log packaging class to automate compiling separate Log entries into log batches.
3030
3131
The class accepts the maximum number of log entries in desired batches and maximum batch size to conform
@@ -35,7 +35,7 @@ class LogBatcher(Generic[T_co]):
3535
entry_num: int
3636
payload_limit: int
3737
_lock: threading.Lock
38-
_batch: list[T_co]
38+
_batch: list[LogRequestType]
3939
_payload_size: int
4040

4141
def __init__(self, entry_num=MAX_LOG_BATCH_SIZE, payload_limit=MAX_LOG_BATCH_PAYLOAD_SIZE) -> None:
@@ -50,7 +50,7 @@ def __init__(self, entry_num=MAX_LOG_BATCH_SIZE, payload_limit=MAX_LOG_BATCH_PAY
5050
self._batch = []
5151
self._payload_size = 0
5252

53-
def _append(self, size: int, log_req: RPRequestLog) -> Optional[list[RPRequestLog]]:
53+
def _append(self, size: int, log_req: LogRequestType) -> Optional[list[LogRequestType]]:
5454
with self._lock:
5555
if self._payload_size + size >= self.payload_limit:
5656
if len(self._batch) > 0:
@@ -74,17 +74,17 @@ def append(self, log_req: RPRequestLog) -> Optional[list[RPRequestLog]]:
7474
:param log_req: log request object
7575
:return: a batch or None
7676
"""
77-
return self._append(log_req.multipart_size, log_req)
77+
return self._append(log_req.multipart_size, log_req) # type: ignore
7878

7979
async def append_async(self, log_req: AsyncRPRequestLog) -> Optional[list[AsyncRPRequestLog]]:
8080
"""Add a log request object to internal batch and return the batch if it's full.
8181
8282
:param log_req: log request object
8383
:return: a batch or None
8484
"""
85-
return self._append(await log_req.multipart_size, log_req)
85+
return self._append(await log_req.multipart_size, log_req) # type: ignore
8686

87-
def flush(self) -> Optional[list[T_co]]:
87+
def flush(self) -> Optional[list[LogRequestType]]:
8888
"""Immediately return everything what's left in the internal batch.
8989
9090
:return: a batch or None

reportportal_client/_internal/services/statistics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def _get_client_info() -> tuple[str, str]:
3737
:return: ('reportportal-client', '5.0.4')
3838
"""
3939
name, version = get_package_parameters("reportportal-client", ["name", "version"])
40-
return name, version
40+
return name or "None", version or "None"
4141

4242

4343
def _get_platform_info() -> str:

reportportal_client/_internal/static/defines.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
10000: "DEBUG",
2727
5000: "TRACE",
2828
}
29+
DEFAULT_LOG_LEVEL = RP_LOG_LEVELS[40000]
2930

3031

3132
class _PresenceSentinel:

0 commit comments

Comments
 (0)