Repository: apify/crawlee-python
File: src/crawlee/storage_clients/_file_system/_request_queue_client.py (Python)

Code before:
                update_modified_at=True,
                update_accessed_at=True,
                new_pending_request_count=0,
            )

            # Invalidate is_empty cache.
            self._is_empty_cache = None

    @override
    async def add_batch_of_requests(
        self,
        requests: Sequence[Request],
        *,
        forefront: bool = False,
    ) -> AddRequestsResponse:
        async with self._lock:
            self._is_empty_cache = None
            new_total_request_count = self._metadata.total_request_count
            new_pending_request_count = self._metadata.pending_request_count
            processed_requests = list[ProcessedRequest]()
            unprocessed_requests = list[UnprocessedRequest]()
            state = self._state.current_value

            all_requests = state.forefront_requests | state.regular_requests

            requests_for_add = {}

            # Determine which requests can be added or are modified.
            for request in requests:
                # Check if the request has already been handled.
                if request.unique_key in state.handled_requests:
                    processed_requests.append(
                        ProcessedRequest(
                            unique_key=request.unique_key,
                            was_already_present=True,
                            was_already_handled=True,
                        )
                    )
                # Check if the request is already in progress.
                # Or if the request is already in the queue and the `forefront` flag is not used, we do not change the
                # position of the request.
                elif (request.unique_key in state.in_progress_requests) or (
                    request.unique_key in all_requests and not forefront
                ):
                    processed_requests.append(
                        ProcessedRequest(
                            unique_key=request.unique_key,
                            was_already_present=True,
                            was_already_handled=False,
                        )
                    )

Review comment (suggestion):
Could we rename this please?

```suggestion
            requests_to_enqueue = {}
```

Code after:
                update_modified_at=True,
                update_accessed_at=True,
                new_pending_request_count=0,
            )

            # Invalidate is_empty cache.
            self._is_empty_cache = None

    @override
    async def add_batch_of_requests(
        self,
        requests: Sequence[Request],
        *,
        forefront: bool = False,
    ) -> AddRequestsResponse:
        async with self._lock:
            self._is_empty_cache = None
            new_total_request_count = self._metadata.total_request_count
            new_pending_request_count = self._metadata.pending_request_count
            processed_requests = list[ProcessedRequest]()
            unprocessed_requests = list[UnprocessedRequest]()
            state = self._state.current_value

            all_requests = state.forefront_requests | state.regular_requests

            requests_to_enqueue = {}

            # Determine which requests can be added or are modified.
            for request in requests:
                # Check if the request has already been handled.
                if request.unique_key in state.handled_requests:
                    processed_requests.append(
                        ProcessedRequest(
                            unique_key=request.unique_key,
                            was_already_present=True,
                            was_already_handled=True,
                        )
                    )
                # Check if the request is already in progress.
                # Or if the request is already in the queue and the `forefront` flag is not used, we do not change the
                # position of the request.
                elif (request.unique_key in state.in_progress_requests) or (
                    request.unique_key in all_requests and not forefront
                ):
                    processed_requests.append(
                        ProcessedRequest(
                            unique_key=request.unique_key,
                            was_already_present=True,
                            was_already_handled=False,
                        )
                    )