Skip to content
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

types in BaseSearchGetRequest? #682

Closed
vincentsarago opened this issue May 3, 2024 · 0 comments · Fixed by #734
Closed

types in BaseSearchGetRequest? #682

vincentsarago opened this issue May 3, 2024 · 0 comments · Fixed by #734

Comments

@vincentsarago
Copy link
Member

class BaseSearchGetRequest(APIRequest):
"""Base arguments for GET Request."""
collections: Optional[str] = attr.ib(default=None, converter=str2list)
ids: Optional[str] = attr.ib(default=None, converter=str2list)
bbox: Optional[BBox] = attr.ib(default=None, converter=str2bbox)
intersects: Optional[str] = attr.ib(default=None)
datetime: Optional[DateTimeType] = attr.ib(default=None, converter=str_to_interval)
limit: Optional[int] = attr.ib(default=10)

there seems to be really weird type definition here:

  • collections is set to Optional[str] but then we use str2list converter to split a string to a list of string
  • same for ids
  • bbox is set to Optional[BBox] but use a converter to convert a string to a list of float
  • datetime is set to Optional[DateTimeType] (Tuple of datetime) and has a str_to_interval converter

IMO it should be either

@attr.s
class BaseSearchGetRequest(APIRequest):
    """Base arguments for GET Request."""

    collections: Optional[str] = attr.ib(default=None, converter=str2list)
    ids: Optional[str] = attr.ib(default=None, converter=str2list)
    bbox: Optional[str] = attr.ib(default=None, converter=str2bbox)
    intersects: Optional[str] = attr.ib(default=None)
    datetime: Optional[str] = attr.ib(default=None, converter=str_to_interval)
    limit: Optional[int] = attr.ib(default=10)

or

@attr.s
class BaseSearchGetRequest(APIRequest):
    """Base arguments for GET Request."""

    collections: Optional[List[str]] = attr.ib(default=None, converter=str2list)
    ids: Optional[List[str]] = attr.ib(default=None, converter=str2list)
    bbox: Optional[BBox] = attr.ib(default=None, converter=str2bbox)
    intersects: Optional[str] = attr.ib(default=None)
    datetime: Optional[DateTimeType] = attr.ib(default=None, converter=str_to_interval)
    limit: Optional[int] = attr.ib(default=10)

FYI, the pydantic Search model is

class Search(BaseModel):
    """
    The base class for STAC API searches.

    https://github.com/radiantearth/stac-api-spec/blob/v1.0.0/item-search/README.md#query-parameter-table
    """

    collections: Optional[List[str]] = None
    ids: Optional[List[str]] = None
    bbox: Optional[BBox] = None
    intersects: Optional[Intersection] = None
    datetime: Optional[str] = None
    limit: int = 10
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 a pull request may close this issue.

1 participant