Skip to content

Commit

Permalink
Argument type update
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Mar 20, 2024
1 parent c4833f3 commit dc7b704
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## [Unreleased]
### Added
- `CONTENT_TYPE_TO_EXTENSIONS` constant in `helpers` module, by @HardNorth
### Changed
- `helpers.gen_attributes` now accepts `Iterable[str]` argument instead of `List[str]`, by @HardNorth

## [5.5.5]
### Added
Expand Down
9 changes: 4 additions & 5 deletions reportportal_client/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import uuid
from platform import machine, processor, system
from types import MappingProxyType
from typing import Optional, Any, List, Dict, Callable, Tuple, Union, TypeVar, Generic
from typing import Optional, Any, List, Dict, Callable, Tuple, Union, TypeVar, Generic, Iterable

from reportportal_client.core.rp_file import RPFile

Expand Down Expand Up @@ -144,15 +144,15 @@ def dict_to_payload(dictionary: Optional[dict]) -> Optional[List[dict]]:
return result


def gen_attributes(rp_attributes: List[str]) -> List[Dict[str, str]]:
def gen_attributes(rp_attributes: Iterable[str]) -> List[Dict[str, str]]:
"""Generate list of attributes for the API request.
Example of input list:
['tag_name:tag_value1', 'tag_value2']
Output of the function for the given input list:
[{'key': 'tag_name', 'value': 'tag_value1'}, {'value': 'tag_value2'}]
:param rp_attributes: List of attributes(tags)
:param rp_attributes: Iterable of attributes(tags)
:return: Correctly created list of dictionaries
to be passed to RP
"""
Expand All @@ -168,8 +168,7 @@ def gen_attributes(rp_attributes: List[str]) -> List[Dict[str, str]]:
if all(attr_dict.values()):
attrs.append(attr_dict)
continue
logger.debug('Failed to process "{0}" attribute, attribute value'
' should not be empty.'.format(rp_attr))
logger.debug(f'Failed to process "{rp_attr}" attribute, attribute value should not be empty.')
return attrs


Expand Down

0 comments on commit dc7b704

Please sign in to comment.