Repository: oppia/oppia
File: core/controllers/android.py (Python)

Code before:
            else:
                fetched_entities = (
                    topic_fetchers.get_multiple_topics_by_ids_and_version(
                        ids_and_versions
                    )
                )

            for activity_data, entity in zip(activities_data, fetched_entities):
                response_dict: ActivityDataResponseDict = {
                    'id': activity_data['id'],
                    'version': activity_data.get('version'),
                    'payload': entity.to_dict() if entity is not None else None,
                }
                activities.append(response_dict)

        self.render_json(activities)


class AndroidPlatformParametersHandler(
    base.BaseHandler[Dict[str, str], Dict[str, str]]
):
    """Handler that returns Android platform parameters for testing."""

    GET_HANDLER_ERROR_RETURN_TYPE = feconf.HANDLER_TYPE_JSON
    URL_PATH_ARGS_SCHEMAS: Dict[str, str] = {}
    # Here we use object because `HANDLER_ARGS_SCHEMAS` may contain
    # schema mappings of different shapes (ints, bools, custom objects),
    # and defining a precise TypedDict for each case is impractical.
    HANDLER_ARGS_SCHEMAS: Dict[str, Dict[str, object]] = {
        'GET': {
            'android_min_version_code_for_recommending_app_update': {
                'schema': {'type': 'int'},
                'default_value': None,
            },
            'android_min_supported_version_code': {
                'schema': {'type': 'int'},
                'default_value': None,
            },
            'android_min_supported_api_level': {
                'schema': {'type': 'int'},
                'default_value': None,
            },
        }
    }

    @acl_decorators.open_access
    def get(self) -> None:
        """Returns platform parameters as a JSON array of objects.

        This is a temporary implementation that allows query parameters to override
        defaults. Schema validation ensures that invalid parameter values result in

Review comment (suggestion):
In this case, it won't; the structure is fairly well determined. Don't use object, please use the exact type (it might be "A or B or C" if there are a few options).

Code after:
                fetched_entities = (
                    topic_fetchers.get_multiple_topics_by_ids_and_version(
                        ids_and_versions
                    )
                )

            for activity_data, entity in zip(activities_data, fetched_entities):
                response_dict: ActivityDataResponseDict = {
                    'id': activity_data['id'],
                    'version': activity_data.get('version'),
                    'payload': entity.to_dict() if entity is not None else None,
                }
                activities.append(response_dict)

        self.render_json(activities)


class AndroidPlatformParametersHandler(
    base.BaseHandler[Dict[str, str], Dict[str, str]]
):
    """Handler that returns Android platform parameters for testing."""

    GET_HANDLER_ERROR_RETURN_TYPE = feconf.HANDLER_TYPE_JSON
    URL_PATH_ARGS_SCHEMAS: Dict[str, str] = {}
    HANDLER_ARGS_SCHEMAS = {
        'GET': {
            'android_min_version_code_for_recommending_app_update': {
                'schema': {'type': 'int'},
                'default_value': None,
            },
            'android_min_supported_version_code': {
                'schema': {'type': 'int'},
                'default_value': None,
            },
            'android_min_supported_api_level': {
                'schema': {'type': 'int'},
                'default_value': None,
            },
        }
    }

    @acl_decorators.open_access
    def get(self) -> None:
        """Returns platform parameters as a JSON array of objects.

        This is a temporary implementation that allows query parameters to override
        defaults. Schema validation ensures that invalid parameter values result in
        a 400 error response.

        Each list item has:
            - name (str): the parameter name.