Repository: apify/crawlee-python
File: src/crawlee/storages/_key_value_store.py (Python)

Code before:
            key: Key of the record to set.
            value: Value to set. If `None`, the record is deleted.
            content_type: Content type of the record.
        """
        if value is None:
            return await self._resource_client.delete_record(key)

        return await self._resource_client.set_record(key, value, content_type)

    async def get_public_url(self, key: str) -> str:
        """Get the public URL for the given key.

        Args:
            key: Key of the record for which URL is required.

        Returns:
            The public URL for the given key.
        """
        return await self._resource_client.get_public_url(key)

    async def get_auto_saved_value(self, key: str, default_value: dict[str, Any] | None = None) -> dict[str, Any]:
        """Gets a value from store that will be automatically saved on changes.

        Args:
            key: Key of the record, to store the value.
            default_value: value to be used if the record does not exist yet. Should be a dictionary

        Returns:
            Returns the value of the key
        """
        default_value = {} if default_value is None else default_value

        if key in self._cache:
            return self._cache[key]

        value = await self.get_value(key, default_value)

        self._cache[key] = value

        self._ensure_persist_event()

        return cast(dict[str, Any], value)

    async def _persist_save(self, _event_data: EventPersistStateData | None = None) -> None:
        """Save cache with persistent values. Can be used in Event Manager."""
        for key, value in self._cache.items():
            await self.set_value(key, value)

    def _ensure_persist_event(self) -> None:
        """Setup persist state event handling if not already done."""
        if self._persist_state_event_started:

Review comment (suggestion):
```suggestion
            default_value: Value to be used if the record does not exist yet. Should be a dictionary.
```

Code after:
        Args:
            key: Key of the record to set.
            value: Value to set. If `None`, the record is deleted.
            content_type: Content type of the record.
        """
        if value is None:
            return await self._resource_client.delete_record(key)

        return await self._resource_client.set_record(key, value, content_type)

    async def get_public_url(self, key: str) -> str:
        """Get the public URL for the given key.

        Args:
            key: Key of the record for which URL is required.

        Returns:
            The public URL for the given key.
        """
        return await self._resource_client.get_public_url(key)

    async def get_auto_saved_value(
        self, key: str, default_value: dict[str, JsonSerializable] | None = None
    ) -> dict[str, JsonSerializable]:
        """Gets a value from KVS that will be automatically saved on changes.

        Args:
            key: Key of the record, to store the value.
            default_value: Value to be used if the record does not exist yet. Should be a dictionary.

        Returns:
            Returns the value of the key.
        """
        default_value = {} if default_value is None else default_value

        if key in self._cache:
            return self._cache[key]

        value = await self.get_value(key, default_value)

        if not isinstance(value, dict):
            raise TypeError(
                f'Expected dictionary for persist state value at key "{key}, but got {type(value).__name__}'
            )

        self._cache[key] = value

        self._ensure_persist_event()

        return value