Skip to content

Unhappiness ensues if user passes datetime for start_date/end_date #99

@philbudne

Description

@philbudne

The typing hints for start_date and end_date in SearchApi params is dt.date, but it's not checked/enforced, and when a dt.datetime is passed, _prep_default_params performs dict(start=start_date.isoformat(), end=end_date.isoformat(), .... resulting in time strings in the request, which the API doesn't handle, and the user sees only a 400 error.

My suggestion is that _prep_default_params check for dt.datetime values, and call thing.date() to truncate AND issue a warning (using warnings.warn?)

Giving better errors would require both

  1. an update to web-search to produce a clear error (see Give a clear error response when API start/end date parse fails web-search#1064)
  2. handling the response here (see Take advantage of new server features #98)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions