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

release: 1.3.0 #21

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.2.0"
".": "1.3.0"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 2
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/find-ai%2Ffind-ai-f1e4b85be4f9018b4c912ee9907f0d1b78c9cbc338257edc23c784e3e4c86331.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/find-ai%2Ffind-ai-decfa532ab550053eca457c16a320bbc460e39619a58f0ef751ebaceaea8660d.yml
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
# Changelog

## 1.3.0 (2024-12-03)

Full Changelog: [v1.2.0...v1.3.0](https://github.com/Find-AI/find-ai-python/compare/v1.2.0...v1.3.0)

### Features

* **api:** manual updates ([#23](https://github.com/Find-AI/find-ai-python/issues/23)) ([ef35843](https://github.com/Find-AI/find-ai-python/commit/ef35843af86df409a07ed8ed8c5869c63fb14e9c))
* **api:** manual updates ([#24](https://github.com/Find-AI/find-ai-python/issues/24)) ([c0f093f](https://github.com/Find-AI/find-ai-python/commit/c0f093fa9809ceff333e07f6cc57112c5fe2ad32))


### Bug Fixes

* **client:** avoid OverflowError with very large retry counts ([#20](https://github.com/Find-AI/find-ai-python/issues/20)) ([7864786](https://github.com/Find-AI/find-ai-python/commit/78647867531c1dacaab324e228d87048c80f93fb))
* **client:** compat with new httpx 0.28.0 release ([#33](https://github.com/Find-AI/find-ai-python/issues/33)) ([ca61cd2](https://github.com/Find-AI/find-ai-python/commit/ca61cd2953ac090de4c950874724fd128d2ac73a))


### Chores

* add repr to PageInfo class ([#22](https://github.com/Find-AI/find-ai-python/issues/22)) ([6472a2f](https://github.com/Find-AI/find-ai-python/commit/6472a2f1f9379b905bcc7f7d70eb2a3da088d09f))
* **internal:** bump pyright ([#34](https://github.com/Find-AI/find-ai-python/issues/34)) ([0364220](https://github.com/Find-AI/find-ai-python/commit/0364220b2d9b7de53b7d382a0ea03adf77c7f87b))
* **internal:** exclude mypy from running on tests ([#32](https://github.com/Find-AI/find-ai-python/issues/32)) ([1a805d6](https://github.com/Find-AI/find-ai-python/commit/1a805d682df0a825a2f91c6968b20b5b33b7850a))
* **internal:** fix compat model_dump method when warnings are passed ([#28](https://github.com/Find-AI/find-ai-python/issues/28)) ([762203b](https://github.com/Find-AI/find-ai-python/commit/762203b6048de50c178f2c3623a6bb6081320f64))
* rebuild project due to codegen change ([#25](https://github.com/Find-AI/find-ai-python/issues/25)) ([4b86eae](https://github.com/Find-AI/find-ai-python/commit/4b86eaedbd6df8fbb7e94f34e2d1a9b945d3530f))
* rebuild project due to codegen change ([#26](https://github.com/Find-AI/find-ai-python/issues/26)) ([7ec6fa4](https://github.com/Find-AI/find-ai-python/commit/7ec6fa4a8efdb19233d684ea84a4682c0b1da503))
* rebuild project due to codegen change ([#27](https://github.com/Find-AI/find-ai-python/issues/27)) ([9592b91](https://github.com/Find-AI/find-ai-python/commit/9592b916168b1a4b38c2df33a3122a9c712b3b75))
* remove now unused `cached-property` dep ([#31](https://github.com/Find-AI/find-ai-python/issues/31)) ([b4a624b](https://github.com/Find-AI/find-ai-python/commit/b4a624bcd94809dbf465134ca12ccea4e7b8b3dc))


### Documentation

* add info log level to readme ([#29](https://github.com/Find-AI/find-ai-python/issues/29)) ([2adc14e](https://github.com/Find-AI/find-ai-python/commit/2adc14ebdcd2fad48ac2b824dc27175d0871690e))

## 1.2.0 (2024-10-08)

Full Changelog: [v1.0.0...v1.2.0](https://github.com/Find-AI/find-ai-python/compare/v1.0.0...v1.2.0)
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![PyPI version](https://img.shields.io/pypi/v/find_ai.svg)](https://pypi.org/project/find_ai/)

The Find AI Python library provides convenient access to the Find AI REST API from any Python 3.7+
The Find AI Python library provides convenient access to the Find AI REST API from any Python 3.8+
application. The library includes type definitions for all request params and response fields,
and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).

Expand All @@ -28,8 +28,7 @@ import os
from find_ai import FindAI

client = FindAI(
# This is the default and can be omitted
api_key=os.environ.get("FIND_AI_API_KEY"),
api_key=os.environ.get("FIND_AI_API_KEY"), # This is the default and can be omitted
)

searches = client.searches.retrieve(
Expand All @@ -52,8 +51,7 @@ import asyncio
from find_ai import AsyncFindAI

client = AsyncFindAI(
# This is the default and can be omitted
api_key=os.environ.get("FIND_AI_API_KEY"),
api_key=os.environ.get("FIND_AI_API_KEY"), # This is the default and can be omitted
)


Expand Down Expand Up @@ -178,12 +176,14 @@ Note that requests that time out are [retried twice by default](#retries).

We use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.

You can enable logging by setting the environment variable `FIND_AI_LOG` to `debug`.
You can enable logging by setting the environment variable `FIND_AI_LOG` to `info`.

```shell
$ export FIND_AI_LOG=debug
$ export FIND_AI_LOG=info
```

Or to `debug` for more verbose logging.

### How to tell whether `None` means `null` or missing

In an API response, a field may be explicitly `null`, or missing entirely; in either case, its value is `None` in this library. You can differentiate the two cases with `.model_fields_set`:
Expand Down Expand Up @@ -326,7 +326,7 @@ print(find_ai.__version__)

## Requirements

Python 3.7 or higher.
Python 3.8 or higher.

## Contributing

Expand Down
5 changes: 4 additions & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ show_error_codes = True
# Exclude _files.py because mypy isn't smart enough to apply
# the correct type narrowing and as this is an internal module
# it's fine to just use Pyright.
exclude = ^(src/find_ai/_files\.py|_dev/.*\.py)$
#
# We also exclude our `tests` as mypy doesn't always infer
# types correctly and Pyright will still catch any type errors.
exclude = ^(src/find_ai/_files\.py|_dev/.*\.py|tests/.*)$

strict_equality = True
implicit_reexport = True
Expand Down
17 changes: 6 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "find_ai"
version = "1.2.0"
version = "1.3.0"
description = "The official Python library for the find-ai API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand All @@ -14,13 +14,11 @@ dependencies = [
"anyio>=3.5.0, <5",
"distro>=1.7.0, <2",
"sniffio",
"cached-property; python_version < '3.8'",
]
requires-python = ">= 3.7"
requires-python = ">= 3.8"
classifiers = [
"Typing :: Typed",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand Down Expand Up @@ -56,18 +54,19 @@ dev-dependencies = [
"dirty-equals>=0.6.0",
"importlib-metadata>=6.7.0",
"rich>=13.7.1",
"nest_asyncio==1.6.0"
]

[tool.rye.scripts]
format = { chain = [
"format:ruff",
"format:docs",
"fix:ruff",
# run formatting again to fix any inconsistencies when imports are stripped
"format:ruff",
]}
"format:black" = "black ."
"format:docs" = "python scripts/utils/ruffen-docs.py README.md api.md"
"format:ruff" = "ruff format"
"format:isort" = "isort ."

"lint" = { chain = [
"check:ruff",
Expand Down Expand Up @@ -125,10 +124,6 @@ path = "README.md"
pattern = '\[(.+?)\]\(((?!https?://)\S+?)\)'
replacement = '[\1](https://github.com/Find-AI/find-ai-python/tree/main/\g<2>)'

[tool.black]
line-length = 120
target-version = ["py37"]

[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "--tb=short"
Expand All @@ -143,7 +138,7 @@ filterwarnings = [
# there are a couple of flags that are still disabled by
# default in strict mode as they are experimental and niche.
typeCheckingMode = "strict"
pythonVersion = "3.7"
pythonVersion = "3.8"

exclude = [
"_dev",
Expand Down
29 changes: 14 additions & 15 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ anyio==4.4.0
# via httpx
argcomplete==3.1.2
# via nox
attrs==23.1.0
# via pytest
certifi==2023.7.22
# via httpcore
# via httpx
Expand All @@ -28,8 +26,9 @@ distlib==0.3.7
# via virtualenv
distro==1.8.0
# via find-ai
exceptiongroup==1.1.3
exceptiongroup==1.2.2
# via anyio
# via pytest
filelock==3.12.4
# via virtualenv
h11==0.14.0
Expand All @@ -49,9 +48,10 @@ markdown-it-py==3.0.0
# via rich
mdurl==0.1.2
# via markdown-it-py
mypy==1.11.2
mypy==1.13.0
mypy-extensions==1.0.0
# via mypy
nest-asyncio==1.6.0
nodeenv==1.8.0
# via pyright
nox==2023.4.22
Expand All @@ -60,27 +60,25 @@ packaging==23.2
# via pytest
platformdirs==3.11.0
# via virtualenv
pluggy==1.3.0
pluggy==1.5.0
# via pytest
py==1.11.0
# via pytest
pydantic==2.7.1
pydantic==2.9.2
# via find-ai
pydantic-core==2.18.2
pydantic-core==2.23.4
# via pydantic
pygments==2.18.0
# via rich
pyright==1.1.380
pytest==7.1.1
pyright==1.1.389
pytest==8.3.3
# via pytest-asyncio
pytest-asyncio==0.21.1
pytest-asyncio==0.24.0
python-dateutil==2.8.2
# via time-machine
pytz==2023.3.post1
# via dirty-equals
respx==0.20.2
rich==13.7.1
ruff==0.6.5
ruff==0.6.9
setuptools==68.2.2
# via nodeenv
six==1.16.0
Expand All @@ -90,15 +88,16 @@ sniffio==1.3.0
# via find-ai
# via httpx
time-machine==2.9.0
tomli==2.0.1
tomli==2.0.2
# via mypy
# via pytest
typing-extensions==4.8.0
typing-extensions==4.12.2
# via anyio
# via find-ai
# via mypy
# via pydantic
# via pydantic-core
# via pyright
virtualenv==20.24.5
# via nox
zipp==3.17.0
Expand Down
8 changes: 4 additions & 4 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ certifi==2023.7.22
# via httpx
distro==1.8.0
# via find-ai
exceptiongroup==1.1.3
exceptiongroup==1.2.2
# via anyio
h11==0.14.0
# via httpcore
Expand All @@ -30,15 +30,15 @@ httpx==0.25.2
idna==3.4
# via anyio
# via httpx
pydantic==2.7.1
pydantic==2.9.2
# via find-ai
pydantic-core==2.18.2
pydantic-core==2.23.4
# via pydantic
sniffio==1.3.0
# via anyio
# via find-ai
# via httpx
typing-extensions==4.8.0
typing-extensions==4.12.2
# via anyio
# via find-ai
# via pydantic
Expand Down
23 changes: 17 additions & 6 deletions src/find_ai/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ def __init__(
self.url = url
self.params = params

@override
def __repr__(self) -> str:
if self.url:
return f"{self.__class__.__name__}(url={self.url})"
return f"{self.__class__.__name__}(params={self.params})"


class BasePage(GenericModel, Generic[_T]):
"""
Expand Down Expand Up @@ -689,7 +695,8 @@ def _calculate_retry_timeout(
if retry_after is not None and 0 < retry_after <= 60:
return retry_after

nb_retries = max_retries - remaining_retries
# Also cap retry count to 1000 to avoid any potential overflows with `pow`
nb_retries = min(max_retries - remaining_retries, 1000)

# Apply exponential backoff, but not more than the max.
sleep_seconds = min(INITIAL_RETRY_DELAY * pow(2.0, nb_retries), MAX_RETRY_DELAY)
Expand Down Expand Up @@ -785,6 +792,7 @@ def __init__(
custom_query: Mapping[str, object] | None = None,
_strict_response_validation: bool,
) -> None:
kwargs: dict[str, Any] = {}
if limits is not None:
warnings.warn(
"The `connection_pool_limits` argument is deprecated. The `http_client` argument should be passed instead",
Expand All @@ -797,6 +805,7 @@ def __init__(
limits = DEFAULT_CONNECTION_LIMITS

if transport is not None:
kwargs["transport"] = transport
warnings.warn(
"The `transport` argument is deprecated. The `http_client` argument should be passed instead",
category=DeprecationWarning,
Expand All @@ -806,6 +815,7 @@ def __init__(
raise ValueError("The `http_client` argument is mutually exclusive with `transport`")

if proxies is not None:
kwargs["proxies"] = proxies
warnings.warn(
"The `proxies` argument is deprecated. The `http_client` argument should be passed instead",
category=DeprecationWarning,
Expand Down Expand Up @@ -849,10 +859,9 @@ def __init__(
base_url=base_url,
# cast to a valid type because mypy doesn't understand our type narrowing
timeout=cast(Timeout, timeout),
proxies=proxies,
transport=transport,
limits=limits,
follow_redirects=True,
**kwargs, # type: ignore
)

def is_closed(self) -> bool:
Expand Down Expand Up @@ -1351,6 +1360,7 @@ def __init__(
custom_headers: Mapping[str, str] | None = None,
custom_query: Mapping[str, object] | None = None,
) -> None:
kwargs: dict[str, Any] = {}
if limits is not None:
warnings.warn(
"The `connection_pool_limits` argument is deprecated. The `http_client` argument should be passed instead",
Expand All @@ -1363,6 +1373,7 @@ def __init__(
limits = DEFAULT_CONNECTION_LIMITS

if transport is not None:
kwargs["transport"] = transport
warnings.warn(
"The `transport` argument is deprecated. The `http_client` argument should be passed instead",
category=DeprecationWarning,
Expand All @@ -1372,6 +1383,7 @@ def __init__(
raise ValueError("The `http_client` argument is mutually exclusive with `transport`")

if proxies is not None:
kwargs["proxies"] = proxies
warnings.warn(
"The `proxies` argument is deprecated. The `http_client` argument should be passed instead",
category=DeprecationWarning,
Expand Down Expand Up @@ -1415,10 +1427,9 @@ def __init__(
base_url=base_url,
# cast to a valid type because mypy doesn't understand our type narrowing
timeout=cast(Timeout, timeout),
proxies=proxies,
transport=transport,
limits=limits,
follow_redirects=True,
**kwargs, # type: ignore
)

def is_closed(self) -> bool:
Expand Down Expand Up @@ -1568,7 +1579,7 @@ async def _request(
except Exception as err:
log.debug("Encountered Exception", exc_info=True)

if retries_taken > 0:
if remaining_retries > 0:
return await self._retry_request(
input_options,
cast_to,
Expand Down
Loading
Loading