Skip to content

Commit 60b9276

Browse files
committed
Type annotations update
1 parent 53e6811 commit 60b9276

File tree

15 files changed

+99
-99
lines changed

15 files changed

+99
-99
lines changed

reportportal_client/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import sys
1717
import warnings
18-
from typing import Optional, Tuple, TypedDict, Union
18+
from typing import Optional, TypedDict, Union
1919

2020
# noinspection PyUnreachableCode
2121
if sys.version_info >= (3, 11):
@@ -60,7 +60,7 @@ class _ClientOptions(TypedDict, total=False):
6060
verify_ssl: Union[bool, str]
6161
retries: int
6262
max_pool_size: int
63-
http_timeout: Union[float, Tuple[float, float]]
63+
http_timeout: Union[float, tuple[float, float]]
6464
mode: str
6565
launch_uuid_print: bool
6666
print_output: OutputType

reportportal_client/_internal/aio/http.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import asyncio
2525
import sys
2626
from types import TracebackType
27-
from typing import Any, Callable, Coroutine, Optional, Type, Union
27+
from typing import Any, Callable, Coroutine, Optional, Union
2828

2929
from aenum import Enum
3030
from aiohttp import ClientResponse, ClientResponseError
@@ -160,7 +160,7 @@ async def __aenter__(self) -> "RetryingClientSession":
160160

161161
async def __aexit__(
162162
self,
163-
exc_type: Optional[Type[BaseException]],
163+
exc_type: Optional[type[BaseException]],
164164
exc_val: Optional[BaseException],
165165
exc_tb: Optional[TracebackType],
166166
) -> None:
@@ -241,7 +241,7 @@ async def __aenter__(self) -> "ClientSession":
241241

242242
async def __aexit__(
243243
self,
244-
exc_type: Optional[Type[BaseException]],
244+
exc_type: Optional[type[BaseException]],
245245
exc_val: Optional[BaseException],
246246
exc_tb: Optional[TracebackType],
247247
) -> None:

reportportal_client/_internal/aio/tasks.py

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

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

@@ -142,7 +142,7 @@ def __call__(
142142
class TriggerTaskBatcher(Generic[_T]):
143143
"""Batching class which compile its batches by object number or by passed time."""
144144

145-
__task_list: List[_T]
145+
__task_list: list[_T]
146146
__last_run_time: float
147147
__trigger_num: int
148148
__trigger_interval: float
@@ -170,7 +170,7 @@ def __ready_to_run(self) -> bool:
170170
return True
171171
return False
172172

173-
def append(self, value: _T) -> Optional[List[_T]]:
173+
def append(self, value: _T) -> Optional[list[_T]]:
174174
"""Add an object to internal batch and return the batch if it's triggered.
175175
176176
:param value: an object to add to the batch
@@ -184,7 +184,7 @@ def append(self, value: _T) -> Optional[List[_T]]:
184184
self.__task_list = []
185185
return tasks
186186

187-
def flush(self) -> Optional[List[_T]]:
187+
def flush(self) -> Optional[list[_T]]:
188188
"""Immediately return everything what's left in the internal batch.
189189
190190
:return: a batch or None
@@ -200,7 +200,7 @@ def flush(self) -> Optional[List[_T]]:
200200
class BackgroundTaskList(Generic[_T]):
201201
"""Task list class which collects Tasks into internal batch and removes when they complete."""
202202

203-
__task_list: List[_T]
203+
__task_list: list[_T]
204204

205205
def __init__(self):
206206
"""Initialize an instance of the Batcher."""
@@ -222,7 +222,7 @@ def append(self, value: _T) -> None:
222222
self.__remove_finished()
223223
self.__task_list.append(value)
224224

225-
def flush(self) -> Optional[List[_T]]:
225+
def flush(self) -> Optional[list[_T]]:
226226
"""Immediately return everything what's left unfinished in the internal batch.
227227
228228
:return: a batch or None

reportportal_client/_internal/http.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"""This module designed to help with synchronous HTTP request/response handling."""
1616

1717
from types import TracebackType
18-
from typing import Any, Callable, Optional, Type, Union
18+
from typing import Any, Callable, Optional, Union
1919

2020
from requests import Response, Session
2121
from requests.adapters import BaseAdapter
@@ -104,7 +104,7 @@ def __enter__(self) -> "ClientSession":
104104

105105
def __exit__(
106106
self,
107-
exc_type: Optional[Type[BaseException]],
107+
exc_type: Optional[type[BaseException]],
108108
exc_val: Optional[BaseException],
109109
exc_tb: Optional[TracebackType],
110110
) -> None:

reportportal_client/_internal/logs/batcher.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import logging
1717
import threading
18-
from typing import Any, Dict, Generic, List, Optional, TypeVar
18+
from typing import Any, Generic, Optional, TypeVar
1919

2020
from reportportal_client.core.rp_requests import AsyncRPRequestLog, RPRequestLog
2121
from reportportal_client.logs import MAX_LOG_BATCH_PAYLOAD_SIZE, MAX_LOG_BATCH_SIZE
@@ -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[T_co]
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: RPRequestLog) -> Optional[list[RPRequestLog]]:
5454
with self._lock:
5555
if self._payload_size + size >= self.payload_limit:
5656
if len(self._batch) > 0:
@@ -68,23 +68,23 @@ def _append(self, size: int, log_req: RPRequestLog) -> Optional[List[RPRequestLo
6868
self._payload_size = 0
6969
return batch
7070

71-
def append(self, log_req: RPRequestLog) -> Optional[List[RPRequestLog]]:
71+
def append(self, log_req: RPRequestLog) -> Optional[list[RPRequestLog]]:
7272
"""Add a log request object to internal batch and return the batch if it's full.
7373
7474
:param log_req: log request object
7575
:return: a batch or None
7676
"""
7777
return self._append(log_req.multipart_size, log_req)
7878

79-
async def append_async(self, log_req: AsyncRPRequestLog) -> Optional[List[AsyncRPRequestLog]]:
79+
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
"""
8585
return self._append(await log_req.multipart_size, log_req)
8686

87-
def flush(self) -> Optional[List[T_co]]:
87+
def flush(self) -> Optional[list[T_co]]:
8888
"""Immediately return everything what's left in the internal batch.
8989
9090
:return: a batch or None
@@ -99,7 +99,7 @@ def flush(self) -> Optional[List[T_co]]:
9999
self._payload_size = 0
100100
return batch
101101

102-
def __getstate__(self) -> Dict[str, Any]:
102+
def __getstate__(self) -> dict[str, Any]:
103103
"""Control object pickling and return object fields as Dictionary.
104104
105105
:return: object state dictionary
@@ -110,7 +110,7 @@ def __getstate__(self) -> Dict[str, Any]:
110110
del state["_lock"]
111111
return state
112112

113-
def __setstate__(self, state: Dict[str, Any]) -> None:
113+
def __setstate__(self, state: dict[str, Any]) -> None:
114114
"""Control object pickling, receives object state as Dictionary.
115115
116116
:param dict state: object state dictionary

reportportal_client/_internal/services/statistics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import logging
1717
import ssl
1818
from platform import python_version
19-
from typing import Optional, Tuple
19+
from typing import Optional
2020

2121
import aiohttp
2222
import certifi
@@ -31,7 +31,7 @@
3131
ID, KEY = CLIENT_INFO.split(":")
3232

3333

34-
def _get_client_info() -> Tuple[str, str]:
34+
def _get_client_info() -> tuple[str, str]:
3535
"""Get name of the client and its version.
3636
3737
:return: ('reportportal-client', '5.0.4')

reportportal_client/aio/client.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import time as datetime
2121
import warnings
2222
from os import getenv
23-
from typing import Any, Coroutine, Dict, List, Optional, Tuple, TypeVar, Union
23+
from typing import Any, Coroutine, Optional, TypeVar, Union
2424

2525
import aiohttp
2626
import certifi
@@ -115,7 +115,7 @@ class Client:
115115
verify_ssl: Union[bool, str]
116116
retries: Optional[int]
117117
max_pool_size: int
118-
http_timeout: Optional[Union[float, Tuple[float, float]]]
118+
http_timeout: Optional[Union[float, tuple[float, float]]]
119119
keepalive_timeout: Optional[float]
120120
mode: str
121121
launch_uuid_print: bool
@@ -135,7 +135,7 @@ def __init__(
135135
verify_ssl: Union[bool, str] = True,
136136
retries: int = NOT_SET,
137137
max_pool_size: int = 50,
138-
http_timeout: Optional[Union[float, Tuple[float, float]]] = (10, 10),
138+
http_timeout: Optional[Union[float, tuple[float, float]]] = (10, 10),
139139
keepalive_timeout: Optional[float] = None,
140140
mode: str = "DEFAULT",
141141
launch_uuid_print: bool = False,
@@ -259,12 +259,12 @@ async def session(self) -> ClientSession:
259259
else:
260260
ssl_config = ssl.create_default_context(ssl.Purpose.SERVER_AUTH, cafile=certifi.where())
261261

262-
connection_params: Dict[str, Any] = {"ssl": ssl_config, "limit": self.max_pool_size}
262+
connection_params: dict[str, Any] = {"ssl": ssl_config, "limit": self.max_pool_size}
263263
if self.keepalive_timeout:
264264
connection_params["keepalive_timeout"] = self.keepalive_timeout
265265
connector = aiohttp.TCPConnector(**connection_params)
266266

267-
session_params: Dict[str, Any] = {"connector": connector}
267+
session_params: dict[str, Any] = {"connector": connector}
268268

269269
if self.http_timeout:
270270
if type(self.http_timeout) is tuple:
@@ -366,7 +366,7 @@ async def start_test_item(
366366
*,
367367
parent_item_id: Optional[Union[str, Task[str]]] = None,
368368
description: Optional[str] = None,
369-
attributes: Optional[Union[List[dict], dict]] = None,
369+
attributes: Optional[Union[list[dict], dict]] = None,
370370
parameters: Optional[dict] = None,
371371
code_ref: Optional[str] = None,
372372
test_case_id: Optional[str] = None,
@@ -629,7 +629,7 @@ async def get_project_settings(self) -> Optional[dict]:
629629
response = await AsyncHttpRequest((await self.session()).get, url=url, name="get_project_settings").make()
630630
return await response.json if response else None
631631

632-
async def log_batch(self, log_batch: Optional[List[AsyncRPRequestLog]]) -> Optional[Tuple[str, ...]]:
632+
async def log_batch(self, log_batch: Optional[list[AsyncRPRequestLog]]) -> Optional[tuple[str, ...]]:
633633
"""Send batch logging message to the ReportPortal.
634634
635635
:param log_batch: A list of log message objects.
@@ -672,7 +672,7 @@ def clone(self) -> "Client":
672672
)
673673
return cloned
674674

675-
def __getstate__(self) -> Dict[str, Any]:
675+
def __getstate__(self) -> dict[str, Any]:
676676
"""Control object pickling and return object fields as Dictionary.
677677
678678
:return: object state dictionary
@@ -683,7 +683,7 @@ def __getstate__(self) -> Dict[str, Any]:
683683
del state["_session"]
684684
return state
685685

686-
def __setstate__(self, state: Dict[str, Any]) -> None:
686+
def __setstate__(self, state: dict[str, Any]) -> None:
687687
"""Control object pickling, receives object state as Dictionary.
688688
689689
:param dict state: object state dictionary
@@ -847,7 +847,7 @@ async def start_test_item(
847847
start_time: str,
848848
item_type: str,
849849
description: Optional[str] = None,
850-
attributes: Optional[List[dict]] = None,
850+
attributes: Optional[list[dict]] = None,
851851
parameters: Optional[dict] = None,
852852
parent_item_id: Optional[str] = None,
853853
has_stats: bool = True,
@@ -1047,7 +1047,7 @@ async def log(
10471047
level: Optional[Union[int, str]] = None,
10481048
attachment: Optional[dict] = None,
10491049
item_id: Optional[str] = None,
1050-
) -> Optional[Tuple[str, ...]]:
1050+
) -> Optional[tuple[str, ...]]:
10511051
"""Send Log message to the ReportPortal and attach it to a Test Item or Launch.
10521052
10531053
This method stores Log messages in internal batch and sent it when batch is full, so not every method
@@ -1293,7 +1293,7 @@ def start_test_item(
12931293
start_time: str,
12941294
item_type: str,
12951295
description: Optional[str] = None,
1296-
attributes: Optional[List[dict]] = None,
1296+
attributes: Optional[list[dict]] = None,
12971297
parameters: Optional[dict] = None,
12981298
parent_item_id: Optional[Task[str]] = None,
12991299
has_stats: bool = True,
@@ -1485,10 +1485,10 @@ def get_project_settings(self) -> Task[Optional[str]]:
14851485
result_task = self.create_task(result_coro)
14861486
return result_task
14871487

1488-
async def _log_batch(self, log_rq: Optional[List[AsyncRPRequestLog]]) -> Optional[Tuple[str, ...]]:
1488+
async def _log_batch(self, log_rq: Optional[list[AsyncRPRequestLog]]) -> Optional[tuple[str, ...]]:
14891489
return await self.__client.log_batch(log_rq)
14901490

1491-
async def _log(self, log_rq: AsyncRPRequestLog) -> Optional[Tuple[str, ...]]:
1491+
async def _log(self, log_rq: AsyncRPRequestLog) -> Optional[tuple[str, ...]]:
14921492
return await self._log_batch(await self._log_batcher.append_async(log_rq))
14931493

14941494
def log(
@@ -1498,7 +1498,7 @@ def log(
14981498
level: Optional[Union[int, str]] = None,
14991499
attachment: Optional[dict] = None,
15001500
item_id: Optional[Task[str]] = None,
1501-
) -> Task[Optional[Tuple[str, ...]]]:
1501+
) -> Task[Optional[tuple[str, ...]]]:
15021502
"""Send Log message to the ReportPortal and attach it to a Test Item or Launch.
15031503
15041504
This method stores Log messages in internal batch and sent it when batch is full, so not every method
@@ -1697,7 +1697,7 @@ def clone(self) -> "ThreadedRPClient":
16971697
cloned._add_current_item(current_item)
16981698
return cloned
16991699

1700-
def __getstate__(self) -> Dict[str, Any]:
1700+
def __getstate__(self) -> dict[str, Any]:
17011701
"""Control object pickling and return object fields as Dictionary.
17021702
17031703
:return: object state dictionary
@@ -1710,7 +1710,7 @@ def __getstate__(self) -> Dict[str, Any]:
17101710
del state["_thread"]
17111711
return state
17121712

1713-
def __setstate__(self, state: Dict[str, Any]) -> None:
1713+
def __setstate__(self, state: dict[str, Any]) -> None:
17141714
"""Control object pickling, receives object state as Dictionary.
17151715
17161716
:param dict state: object state dictionary
@@ -1889,7 +1889,7 @@ def clone(self) -> "BatchedRPClient":
18891889
cloned._add_current_item(current_item)
18901890
return cloned
18911891

1892-
def __getstate__(self) -> Dict[str, Any]:
1892+
def __getstate__(self) -> dict[str, Any]:
18931893
"""Control object pickling and return object fields as Dictionary.
18941894
18951895
:return: object state dictionary
@@ -1901,7 +1901,7 @@ def __getstate__(self) -> Dict[str, Any]:
19011901
del state["_loop"]
19021902
return state
19031903

1904-
def __setstate__(self, state: Dict[str, Any]) -> None:
1904+
def __setstate__(self, state: dict[str, Any]) -> None:
19051905
"""Control object pickling, receives object state as Dictionary.
19061906
19071907
:param dict state: object state dictionary

0 commit comments

Comments
 (0)