Skip to content

Fix typing of base_model and mixins parameters #852

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant