Skip to content

release: 0.17.0 #325

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

Merged
merged 13 commits into from
Mar 29, 2024
Merged
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 @@
{
".": "0.16.8"
".": "0.17.0"
}
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,40 @@
# Changelog

## 0.17.0 (2024-03-29)

Full Changelog: [v0.16.8...v0.17.0](https://github.com/Finch-API/finch-api-python/compare/v0.16.8...v0.17.0)

### Features

* **package:** export default constants ([#334](https://github.com/Finch-API/finch-api-python/issues/334)) ([6ee4799](https://github.com/Finch-API/finch-api-python/commit/6ee479969a3ac25ed98d5e93bbcacf58d1171529))


### Bug Fixes

* **project:** use absolute github links on PyPi ([#335](https://github.com/Finch-API/finch-api-python/issues/335)) ([f44d11c](https://github.com/Finch-API/finch-api-python/commit/f44d11caf7c2869470d941025083e29b6104ef21))
* revert regression with 3.7 support ([#332](https://github.com/Finch-API/finch-api-python/issues/332)) ([da0031c](https://github.com/Finch-API/finch-api-python/commit/da0031cd66a123f339a65ad63a731e97ad65383f))


### Performance Improvements

* cache TypeAdapters ([#324](https://github.com/Finch-API/finch-api-python/issues/324)) ([3bd22fe](https://github.com/Finch-API/finch-api-python/commit/3bd22fe8a9fe02f2700ac0b6387b00575cddc444))


### Chores

* **internal:** formatting change ([#330](https://github.com/Finch-API/finch-api-python/issues/330)) ([6b8829f](https://github.com/Finch-API/finch-api-python/commit/6b8829f4999a3e243d63f45126000b5ad2a6b9ef))
* **internal:** loosen input type for util function ([#328](https://github.com/Finch-API/finch-api-python/issues/328)) ([3fdcf2e](https://github.com/Finch-API/finch-api-python/commit/3fdcf2e89f9ba3ef341e0402d3cfd528ad568af5))
* **internal:** update generated pragma comment ([#327](https://github.com/Finch-API/finch-api-python/issues/327)) ([269569f](https://github.com/Finch-API/finch-api-python/commit/269569fdca6c03dc8202dab0b20e00c099020d65))
* revert temporary commit ([7961a22](https://github.com/Finch-API/finch-api-python/commit/7961a22b10e052807d02fd09c9ae7d07c30391af))
* temporary commit ([#333](https://github.com/Finch-API/finch-api-python/issues/333)) ([5e42474](https://github.com/Finch-API/finch-api-python/commit/5e42474c6a00a6ec3e8a11db753ffbecb6e9a1e3))


### Documentation

* **contributing:** fix typo ([#331](https://github.com/Finch-API/finch-api-python/issues/331)) ([15c71d5](https://github.com/Finch-API/finch-api-python/commit/15c71d5bc77fda5bb4b2f7aec53c75f49987ae3b))
* fix typo in CONTRIBUTING.md ([#326](https://github.com/Finch-API/finch-api-python/issues/326)) ([98ba71b](https://github.com/Finch-API/finch-api-python/commit/98ba71b32ab2eaa1564b0fbab85cb2de9a0ea421))
* **readme:** document how to make undocumented requests ([#329](https://github.com/Finch-API/finch-api-python/issues/329)) ([55bf27d](https://github.com/Finch-API/finch-api-python/commit/55bf27d677d81c1272b148ec37fdac8b5dd4fc68))

## 0.16.8 (2024-03-11)

Full Changelog: [v0.16.7...v0.16.8](https://github.com/Finch-API/finch-api-python/compare/v0.16.7...v0.16.8)
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Most tests require you to [set up a mock server](https://github.com/stoplightio/

```bash
# you will need npm installed
npx prism path/to/your/openapi.yml
npx prism mock path/to/your/openapi.yml
```

```bash
Expand Down Expand Up @@ -121,5 +121,5 @@ You can release to package managers by using [the `Publish PyPI` GitHub action](

### Publish manually

If you need to manually release a package, you can run the `bin/publish-pypi` script with an `PYPI_TOKEN` set on
If you need to manually release a package, you can run the `bin/publish-pypi` script with a `PYPI_TOKEN` set on
the environment.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,41 @@ with client.hris.directory.with_streaming_response.list() as response:

The context manager is required so that the response will reliably be closed.

### Making custom/undocumented requests

This library is typed for convenient access the documented API.

If you need to access undocumented endpoints, params, or response properties, the library can still be used.

#### Undocumented endpoints

To make requests to undocumented endpoints, you can make requests using `client.get`, `client.post`, and other
http verbs. Options on the client will be respected (such as retries) will be respected when making this
request.

```py
import httpx

response = client.post(
"/foo",
cast_to=httpx.Response,
body={"my_param": True},
)

print(response.headers.get("x-foo"))
```

#### Undocumented params

If you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` request
options.

#### Undocumented properties

To access undocumented response properties, you can access the extra fields like `response.unknown_prop`. You
can also get all the extra fields on the Pydantic model as a dict with
[`response.model_extra`](https://docs.pydantic.dev/latest/api/base_model/#pydantic.BaseModel.model_extra).

### Configuring the HTTP client

You can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including:
Expand Down
18 changes: 15 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[project]
name = "finch-api"
version = "0.16.8"
version = "0.17.0"
description = "The official Python library for the Finch API"
readme = "README.md"
dynamic = ["readme"]
license = "Apache-2.0"
authors = [
{ name = "Finch", email = "[email protected]" },
Expand Down Expand Up @@ -88,7 +88,7 @@ typecheck = { chain = [
"typecheck:mypy" = "mypy ."

[build-system]
requires = ["hatchling"]
requires = ["hatchling", "hatch-fancy-pypi-readme"]
build-backend = "hatchling.build"

[tool.hatch.build]
Expand All @@ -99,6 +99,17 @@ include = [
[tool.hatch.build.targets.wheel]
packages = ["src/finch"]

[tool.hatch.metadata.hooks.fancy-pypi-readme]
content-type = "text/markdown"

[[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]]
path = "README.md"

[[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
# replace relative links with absolute links
pattern = '\[(.+?)\]\(((?!https?://)\S+?)\)'
replacement = '[\1](https://github.com/Finch-API/finch-api-python/tree/main/\g<2>)'

[tool.black]
line-length = 120
target-version = ["py37"]
Expand Down Expand Up @@ -130,6 +141,7 @@ reportImplicitOverride = true
reportImportCycles = false
reportPrivateUsage = false


[tool.ruff]
line-length = 120
output-format = "grouped"
Expand Down
6 changes: 5 additions & 1 deletion src/finch/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless.
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from . import types
from ._types import NOT_GIVEN, NoneType, NotGiven, Transport, ProxiesTypes
Expand All @@ -7,6 +7,7 @@
from ._models import BaseModel
from ._version import __title__, __version__
from ._response import APIResponse as APIResponse, AsyncAPIResponse as AsyncAPIResponse
from ._constants import DEFAULT_TIMEOUT, DEFAULT_MAX_RETRIES, DEFAULT_CONNECTION_LIMITS
from ._exceptions import (
APIError,
FinchError,
Expand Down Expand Up @@ -58,6 +59,9 @@
"AsyncFinch",
"file_from_path",
"BaseModel",
"DEFAULT_TIMEOUT",
"DEFAULT_MAX_RETRIES",
"DEFAULT_CONNECTION_LIMITS",
]

_setup_logging()
Expand Down
6 changes: 3 additions & 3 deletions src/finch/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@
extract_response_type,
)
from ._constants import (
DEFAULT_LIMITS,
DEFAULT_TIMEOUT,
MAX_RETRY_DELAY,
DEFAULT_MAX_RETRIES,
INITIAL_RETRY_DELAY,
RAW_RESPONSE_HEADER,
OVERRIDE_CAST_TO_HEADER,
DEFAULT_CONNECTION_LIMITS,
)
from ._streaming import Stream, SSEDecoder, AsyncStream, SSEBytesDecoder
from ._exceptions import (
Expand Down Expand Up @@ -747,7 +747,7 @@ def __init__(
if http_client is not None:
raise ValueError("The `http_client` argument is mutually exclusive with `connection_pool_limits`")
else:
limits = DEFAULT_LIMITS
limits = DEFAULT_CONNECTION_LIMITS

if transport is not None:
warnings.warn(
Expand Down Expand Up @@ -1294,7 +1294,7 @@ def __init__(
if http_client is not None:
raise ValueError("The `http_client` argument is mutually exclusive with `connection_pool_limits`")
else:
limits = DEFAULT_LIMITS
limits = DEFAULT_CONNECTION_LIMITS

if transport is not None:
warnings.warn(
Expand Down
8 changes: 4 additions & 4 deletions src/finch/_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless.
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

Expand Down Expand Up @@ -30,8 +30,8 @@
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
from ._exceptions import APIStatusError
from ._base_client import (
DEFAULT_LIMITS,
DEFAULT_MAX_RETRIES,
DEFAULT_CONNECTION_LIMITS,
SyncAPIClient,
AsyncAPIClient,
SyncHttpxClientWrapper,
Expand Down Expand Up @@ -273,7 +273,7 @@ def copy(

http_client = None
else:
if self._limits is not DEFAULT_LIMITS:
if self._limits is not DEFAULT_CONNECTION_LIMITS:
connection_pool_limits = self._limits
else:
connection_pool_limits = None
Expand Down Expand Up @@ -621,7 +621,7 @@ def copy(

http_client = None
else:
if self._limits is not DEFAULT_LIMITS:
if self._limits is not DEFAULT_CONNECTION_LIMITS:
connection_pool_limits = self._limits
else:
connection_pool_limits = None
Expand Down
4 changes: 2 additions & 2 deletions src/finch/_constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless.
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import httpx

Expand All @@ -8,7 +8,7 @@
# default timeout is 1 minute
DEFAULT_TIMEOUT = httpx.Timeout(timeout=60.0, connect=5.0)
DEFAULT_MAX_RETRIES = 2
DEFAULT_LIMITS = httpx.Limits(max_connections=100, max_keepalive_connections=20)
DEFAULT_CONNECTION_LIMITS = httpx.Limits(max_connections=100, max_keepalive_connections=20)

INITIAL_RETRY_DELAY = 0.5
MAX_RETRY_DELAY = 8.0
2 changes: 1 addition & 1 deletion src/finch/_exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless.
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

Expand Down
16 changes: 14 additions & 2 deletions src/finch/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import inspect
from typing import TYPE_CHECKING, Any, Type, Union, Generic, TypeVar, Callable, cast
from datetime import date, datetime
from functools import lru_cache
from typing_extensions import (
Unpack,
Literal,
Expand Down Expand Up @@ -289,11 +290,15 @@ def is_basemodel_type(type_: type) -> TypeGuard[type[BaseModel] | type[GenericMo
return issubclass(origin, BaseModel) or issubclass(origin, GenericModel)


def construct_type(*, value: object, type_: type) -> object:
def construct_type(*, value: object, type_: object) -> object:
"""Loose coercion to the expected type with construction of nested values.

If the given value does not match the expected type then it is returned as-is.
"""
# we allow `object` as the input type because otherwise, passing things like
# `Literal['value']` will be reported as a type error by type checkers
type_ = cast("type[object]", type_)

# unwrap `Annotated[T, ...]` -> `T`
if is_annotated_type(type_):
meta = get_args(type_)[1:]
Expand Down Expand Up @@ -533,7 +538,14 @@ class GenericModel(BaseGenericModel, BaseModel):


if PYDANTIC_V2:
from pydantic import TypeAdapter
from pydantic import TypeAdapter as _TypeAdapter

_CachedTypeAdapter = cast("TypeAdapter[object]", lru_cache(maxsize=None)(_TypeAdapter))

if TYPE_CHECKING:
from pydantic import TypeAdapter
else:
TypeAdapter = _CachedTypeAdapter

def _validate_non_model_type(*, type_: type[_T], value: object) -> _T:
return TypeAdapter(type_).validate_python(value)
Expand Down
2 changes: 1 addition & 1 deletion src/finch/_resource.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless.
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

Expand Down
4 changes: 2 additions & 2 deletions src/finch/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless.
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "finch"
__version__ = "0.16.8" # x-release-please-version
__version__ = "0.17.0" # x-release-please-version
2 changes: 1 addition & 1 deletion src/finch/pagination.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless.
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import Any, List, Type, Generic, Mapping, TypeVar, Optional, cast
from typing_extensions import override
Expand Down
2 changes: 1 addition & 1 deletion src/finch/resources/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless.
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from .hris import (
HRIS,
Expand Down
2 changes: 1 addition & 1 deletion src/finch/resources/access_tokens.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless.
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

Expand Down
2 changes: 1 addition & 1 deletion src/finch/resources/account.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless.
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

Expand Down
2 changes: 1 addition & 1 deletion src/finch/resources/hris/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless.
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from .hris import (
HRIS,
Expand Down
2 changes: 1 addition & 1 deletion src/finch/resources/hris/benefits/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless.
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from .benefits import (
Benefits,
Expand Down
2 changes: 1 addition & 1 deletion src/finch/resources/hris/benefits/benefits.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless.
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

Expand Down
2 changes: 1 addition & 1 deletion src/finch/resources/hris/benefits/individuals.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless.
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

Expand Down
2 changes: 1 addition & 1 deletion src/finch/resources/hris/company.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless.
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

Expand Down
2 changes: 1 addition & 1 deletion src/finch/resources/hris/directory.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless.
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

Expand Down
2 changes: 1 addition & 1 deletion src/finch/resources/hris/employments.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless.
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

Expand Down
2 changes: 1 addition & 1 deletion src/finch/resources/hris/hris.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless.
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

Expand Down
2 changes: 1 addition & 1 deletion src/finch/resources/hris/individuals.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless.
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

Expand Down
Loading