diff --git a/HISTORY.md b/HISTORY.md index df7e84a..63644de 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -6,7 +6,7 @@ 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). -## [5.0.1](https://github.com/uploadcare/pyuploadcare/compare/v5.0.0...v5.0.1) - unreleased +## [5.0.1](https://github.com/uploadcare/pyuploadcare/compare/v5.0.0...v5.0.1) - 2024-03-02 ### Changed @@ -14,7 +14,8 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### Fixed -- The SSL context is now cached by default, resulting in significant performance improvements when initializing the `Uploadcare` class frequently. [#279](https://github.com/uploadcare/pyuploadcare/issues/279) +- The SSL context is now cached by default, resulting in significant performance improvements when initializing the `Uploadcare` class frequently. [#279](https://github.com/uploadcare/pyuploadcare/issues/279) +- Removed the warning for the usage of the deprecated `pydantic.utils.deep_update` [#283](https://github.com/uploadcare/pyuploadcare/issues/283) ## [5.0.0](https://github.com/uploadcare/pyuploadcare/compare/v4.3.0...v5.0.0) - 2023-12-28 diff --git a/pyuploadcare/dj/conf.py b/pyuploadcare/dj/conf.py index b036280..1a8b715 100644 --- a/pyuploadcare/dj/conf.py +++ b/pyuploadcare/dj/conf.py @@ -7,9 +7,9 @@ from django import get_version as django_version from django.conf import settings from django.core.exceptions import ImproperlyConfigured -from pydantic.utils import deep_update from pyuploadcare import __version__ as library_version +from pyuploadcare.helpers import deep_update __all__ = [ diff --git a/pyuploadcare/helpers.py b/pyuploadcare/helpers.py index 0b2ec04..b9f0fa7 100644 --- a/pyuploadcare/helpers.py +++ b/pyuploadcare/helpers.py @@ -1,6 +1,6 @@ import mimetypes import os -from typing import IO, Iterable, List, TypeVar, Union +from typing import IO, Any, Dict, Iterable, List, TypeVar, Union from pyuploadcare import File @@ -48,3 +48,23 @@ def guess_mime_type(file_object: IO) -> str: if not mime_type: mime_type = "application/octet-stream" return mime_type + + +KeyType = TypeVar("KeyType") + + +def deep_update( + mapping: Dict[KeyType, Any], *updating_mappings: Dict[KeyType, Any] +) -> Dict[KeyType, Any]: + updated_mapping = mapping.copy() + for updating_mapping in updating_mappings: + for k, v in updating_mapping.items(): + if ( + k in updated_mapping + and isinstance(updated_mapping[k], dict) + and isinstance(v, dict) + ): + updated_mapping[k] = deep_update(updated_mapping[k], v) + else: + updated_mapping[k] = v + return updated_mapping