Skip to content

Commit

Permalink
Merge pull request #272 from uploadcare/bugfix/260-allow_dicts_for_ad…
Browse files Browse the repository at this point in the history
…don_execution_params

fix AttributeError: 'dict' object has no attribute 'dict' in AddonsAPI
  • Loading branch information
evgkirov authored Nov 17, 2023
2 parents c897f7d + 2e98248 commit ac26ce4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
7 changes: 7 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ The format is based on [Keep a
Changelog](https://keepachangelog.com/en/1.0.0/), and this project
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [4.2.1](https://github.com/uploadcare/pyuploadcare/compare/v4.2.0...v4.2.1) - 2023-11-17

### Fixed

- For `AddonsAPI`:
- In version 4.2.0, passing a Python dictionary as `params` to the `execute` method would cause an `AttributeError`. Now, you can use either an `AddonExecutionParams` instance or a `dict`.

## [4.2.0](https://github.com/uploadcare/pyuploadcare/compare/v4.1.3...v4.2.0) - 2023-11-16

Summary of this update:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyuploadcare"
version = "4.2.0"
version = "4.2.1"
description = "Python library for Uploadcare.com"
authors = ["Uploadcare Inc <[email protected]>"]
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion pyuploadcare/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# isort: skip_file
__version__ = "4.2.0"
__version__ = "4.2.1"

from pyuploadcare.resources.file import File # noqa: F401
from pyuploadcare.resources.file_group import FileGroup # noqa: F401
Expand Down
11 changes: 8 additions & 3 deletions pyuploadcare/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,11 +522,16 @@ class AddonsAPI(API):
def _get_request_data(
self,
file_uuid: Union[UUID, str],
params: Optional[AddonExecutionParams] = None,
params: Optional[Union[AddonExecutionParams, dict]] = None,
) -> dict:
cleaned_params = {}
if params:
cleaned_params = params.dict(exclude_unset=True, exclude_none=True)
if isinstance(params, AddonExecutionParams):
cleaned_params = params.dict(
exclude_unset=True, exclude_none=True
)
else:
cleaned_params = params
execution_request_data = self.request_type.parse_obj(
dict(target=str(file_uuid), params=cleaned_params)
)
Expand All @@ -538,7 +543,7 @@ def execute(
self,
file_uuid: Union[UUID, str],
addon_name: Union[AddonLabels, str],
params: Optional[AddonExecutionParams] = None,
params: Optional[Union[AddonExecutionParams, dict]] = None,
) -> responses.AddonExecuteResponse:
if isinstance(addon_name, AddonLabels):
addon_name = addon_name.value
Expand Down

0 comments on commit ac26ce4

Please sign in to comment.