Predicthq

Latest version: v3.4.0

Safety actively analyzes 621724 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

42.346

phq.events.search(within__radius="2km", within__longitude=-71.0432, within__latitude=42.346)


Since we are not loading the query params data into objects and not validating it anymore, only the first example will be available from now on (which is the format described in [our documentation](https://docs.predicthq.com/api/events/search-events))

So if you were using the `within` filter sequentially, using `__` or with a dictionary, you will need to update it as follows
python
phq.events.search(within="10km-36.844480,174.768368")


Exception update
Previously, if you would provide an incorect parameter to an endpoint, the method would raise a `predicthq.exceptions.ValidationError`.

This error would be formatted as follows

predicthq.exceptions.ValidationError: {'<field_name>': '<reason>'}


Since we are not performing validation within the SDK, the raised exception will instead contain the error message provided by our API.

The exception type has also been changed from `predicthq.exceptions.ValidationError` to `predicthq.exceptions.ClientError`.

Those errors will be formatted as follows

{'error': '<API Error description>', 'code': 400}


Cannot use classes as query parameters anymore
Our endpoints used to allow users to use a `schematics` instance as a query parameter when querying our APIs.

e.g.
python
from predicthq import Client
from predicthq.endpoints.v1.events.schemas import SearchParams

phq = Client(access_token="abc123")

query_params = SearchParams().import_data({
"q": "Katy Perry",
"state": ["active"],
"rank_level": [4, 5],
"category": "concerts"
})

for event in phq.events.search(query_params):
print(event.rank, event.category, event.title, event.start.strftime("%Y-%m-%d"))


This feature was undocumented, so we are not expecting many or anyone to have used it ever.

In the unlikely event that you were using those, you will need to update it as one of the following as this is not supported anymore

python
from predicthq import Client
from predicthq.endpoints.v1.events.schemas import SearchParams

phq = Client(access_token="abc123")

query_params = {
"q": "Katy Perry",
"state": ["active"],
"rank_level": [4, 5],
"category": "concerts"
}

Either

for event in phq.events.search(**query_params):
print(event.rank, event.category, event.title, event.start.strftime("%Y-%m-%d"))

OR

for event in phq.events.search(q="Katy Perry", state=["active"], rank_level=[4, 5], category="concerts"):
print(event.rank, event.category, event.title, event.start.strftime("%Y-%m-%d"))

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.