Skip to content

Conversation

vprivat-ads
Copy link
Contributor

@vprivat-ads vprivat-ads commented Aug 11, 2025

Related Issue(s):

We have this code in our downstream application, taken straight from stac-fastapi tests:

from stac_fastapi.api.models import (
    ItemCollectionUri,
    create_request_model,
)

items_get_request_model = create_request_model(
    "ItemCollectionURI",
    base_model=ItemCollectionUri,
    mixins=[TokenPaginationExtension().GET],
)

which raises these mypy errors when trying to update to stac-fastapi 6.0.0, probably because of #842:

services/catalog/rs_server_catalog/main.py:253: error: Argument "base_model" to "create_request_model" has incompatible type "type[ItemCollectionUri]"; expected "type[BaseModel] | APIRequest"  [arg-type]
services/catalog/rs_server_catalog/main.py:254: error: Argument "mixins" to "create_request_model" has incompatible type "list[type[GETTokenPagination]]"; expected "list[BaseModel] | list[APIRequest] | None"  [arg-type]

I believe the definition of base_model and mixins are wrong:

    base_model: Union[Type[BaseModel], APIRequest] = BaseSearchGetRequest,
    mixins: Optional[Union[List[BaseModel], List[APIRequest]]] = None,

Description:

Change the definition of base_model and mixins to accept types:

    base_model: Union[Type[BaseModel], Type[APIRequest]] = BaseSearchGetRequest,
    mixins: Optional[Union[List[Type[BaseModel]], List[Type[APIRequest]]]] = None,

PR Checklist:

  • pre-commit hooks pass locally
  • Tests pass (run make test)
  • Documentation has been updated to reflect changes, if applicable, and docs build successfully (run make docs)
  • Changes are added to the CHANGELOG.

@vprivat-ads vprivat-ads marked this pull request as draft August 11, 2025 14:28
@vprivat-ads vprivat-ads changed the title Fix typing of base_model parameter Fix typing of base_model and mixins parameters Aug 11, 2025
@vprivat-ads vprivat-ads marked this pull request as ready for review August 11, 2025 14:41
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant