Skip to content

Commit 8ee4100

Browse files
committed
A try to fix imports
1 parent 3c403f0 commit 8ee4100

4 files changed

Lines changed: 37 additions & 23 deletions

File tree

reportportal_client/aio/__init__.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
# limitations under the License
1313

1414
"""Common package for Asynchronous I/O clients and utilities."""
15-
import asyncio
16-
from typing import Coroutine, Optional, TypeVar, Union
1715

1816
from reportportal_client.aio.client import (
1917
DEFAULT_SHUTDOWN_TIMEOUT,
@@ -26,25 +24,7 @@
2624
)
2725
from reportportal_client.aio.tasks import BlockingOperationError, EmptyTask, Task
2826

29-
_T = TypeVar("_T")
30-
31-
32-
async def await_if_necessary(obj: Union[_T, Task[_T], Coroutine[_T, None, None]]) -> Optional[_T]:
33-
"""Await Coroutine, Feature or coroutine Function if given argument is one of them, or return immediately.
34-
35-
:param obj: value, Coroutine, Feature or coroutine Function
36-
:return: result which was returned by Coroutine, Feature or coroutine Function
37-
"""
38-
if obj:
39-
if asyncio.isfuture(obj) or asyncio.iscoroutine(obj):
40-
return await obj
41-
elif asyncio.iscoroutinefunction(obj):
42-
return await obj()
43-
return obj
44-
45-
4627
__all__ = [
47-
"await_if_necessary",
4828
"Task",
4929
"EmptyTask",
5030
"BlockingOperationError",

reportportal_client/aio/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@
5656
# noinspection PyProtectedMember
5757
from reportportal_client._internal.static.abstract import AbstractBaseClass, abstractmethod
5858
from reportportal_client._internal.static.defines import DEFAULT_LOG_LEVEL
59-
from reportportal_client.aio import EmptyTask, await_if_necessary
6059

6160
# noinspection PyProtectedMember
62-
from reportportal_client.aio.tasks import Task
61+
from reportportal_client.aio.tasks import EmptyTask, Task
62+
from reportportal_client.aio.util import await_if_necessary
6363
from reportportal_client.client import RP, OutputType
6464
from reportportal_client.core.rp_issues import Issue
6565
from reportportal_client.core.rp_requests import (

reportportal_client/aio/util.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright 2026 EPAM Systems
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import asyncio
16+
from typing import Coroutine, Optional, TypeVar, Union
17+
18+
from reportportal_client.aio.tasks import Task
19+
20+
_T = TypeVar("_T")
21+
22+
23+
async def await_if_necessary(obj: Union[_T, Task[_T], Coroutine[_T, None, None]]) -> Optional[_T]:
24+
"""Await Coroutine, Feature or coroutine Function if given argument is one of them, or return immediately.
25+
26+
:param obj: value, Coroutine, Feature or coroutine Function
27+
:return: result which was returned by Coroutine, Feature or coroutine Function
28+
"""
29+
if obj:
30+
if asyncio.isfuture(obj) or asyncio.iscoroutine(obj):
31+
return await obj
32+
elif asyncio.iscoroutinefunction(obj):
33+
return await obj()
34+
return obj

reportportal_client/core/rp_requests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
# noinspection PyProtectedMember
3939
from reportportal_client._internal.static.defines import DEFAULT_LOG_LEVEL, DEFAULT_PRIORITY, LOW_PRIORITY, Priority
40-
from reportportal_client.aio import await_if_necessary
40+
from reportportal_client.aio.util import await_if_necessary
4141
from reportportal_client.core.rp_file import RPFile
4242
from reportportal_client.core.rp_issues import Issue
4343
from reportportal_client.core.rp_responses import AsyncRPResponse, RPResponse

0 commit comments

Comments
 (0)