Skip to content
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
29 changes: 29 additions & 0 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This workflow is triggered when a GitHub release is created.
# It can also be run manually to re-publish to PyPI in case it failed for some reason.
# You can run this workflow by navigating to https://www.github.com/unifygtm/sdk-python/actions/workflows/publish-pypi.yml
name: Publish PyPI
on:
workflow_dispatch:

release:
types: [published]

jobs:
publish:
name: publish
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write

steps:
- uses: actions/checkout@v6

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: '0.9.13'

- name: Publish to PyPI
run: |
bash ./bin/publish-pypi
19 changes: 19 additions & 0 deletions .github/workflows/release-doctor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Release Doctor
on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
release_doctor:
name: release doctor
runs-on: ubuntu-latest
if: github.repository == 'unifygtm/sdk-python' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next')

steps:
- uses: actions/checkout@v6

- name: Check release environment
run: |
bash ./bin/check-release-environment
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "0.1.0"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 21
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/unify%2Funify-ebac54fcc7f9310ca978e40329e4ad0280d12e6002caa30d33c0d21854d0e078.yml
openapi_spec_hash: ed7be17146f8578360792a4e48168a83
config_hash: 03cb0b348b569fee11bfc22476f06e35
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/unify%2Funify-17c3b84a98900702272afd48aea1815a914796c8b8d2ff9ac958f58b61397add.yml
openapi_spec_hash: 669c33d5b065c8cd22fc2c166214cbdc
config_hash: 733f711df6a401fc87fd4c8a0957d89f
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Changelog

## 0.1.0 (2026-04-22)

Full Changelog: [v0.0.1...v0.1.0](https://github.com/unifygtm/sdk-python/compare/v0.0.1...v0.1.0)

### Features

* **api:** Export additional models ([dfd35c4](https://github.com/unifygtm/sdk-python/commit/dfd35c4237cd76f7a98756099578a3d5a7fbe49c))
* **api:** Fix address key names ([d242e4d](https://github.com/unifygtm/sdk-python/commit/d242e4d1ffea3ec22bdf087b99c29ff1e7648088))


### Performance Improvements

* **client:** optimize file structure copying in multipart requests ([415dc8c](https://github.com/unifygtm/sdk-python/commit/415dc8c5c0f05213e2a76965aa84dd8025f3e266))


### Chores

* configure new SDK language ([d9df84f](https://github.com/unifygtm/sdk-python/commit/d9df84fd44ccf04618c1a826108090c26abfa697))
* update SDK settings ([3366ab9](https://github.com/unifygtm/sdk-python/commit/3366ab929576d671d1f638a68a72e67e6c647a93))
* update SDK settings ([602adef](https://github.com/unifygtm/sdk-python/commit/602adef3556b2f0995d753bc698fa267d6af354c))
* update SDK settings ([d25cd0a](https://github.com/unifygtm/sdk-python/commit/d25cd0ae33729447238a65102927be63f4cb73df))
* update SDK settings ([155420b](https://github.com/unifygtm/sdk-python/commit/155420bd67fa749d4620f6bea553adea34ffbe1f))
* update SDK settings ([d40fd07](https://github.com/unifygtm/sdk-python/commit/d40fd0757d59b0899234d662ba3410a68899d4ad))
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ If you’d like to use the repository from source, you can either install from g
To install via git:

```sh
$ pip install git+ssh://git@github.com/stainless-sdks/unify-python.git
$ pip install git+ssh://git@github.com/unifygtm/sdk-python.git
```

Alternatively, you can build from source and install the wheel file:
Expand Down Expand Up @@ -113,7 +113,7 @@ the changes aren't made through the automated pipeline, you may want to make rel

### Publish with a GitHub workflow

You can release to package managers by using [the `Publish PyPI` GitHub action](https://www.github.com/stainless-sdks/unify-python/actions/workflows/publish-pypi.yml). This requires a setup organization or repository secret to be set up.
You can release to package managers by using [the `Publish PyPI` GitHub action](https://www.github.com/unifygtm/sdk-python/actions/workflows/publish-pypi.yml). This requires a setup organization or repository secret to be set up.

### Publish manually

Expand Down
17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@ The REST API documentation can be found on [docs.unifygtm.com](https://docs.unif
## Installation

```sh
# install from this staging repo
pip install git+ssh://git@github.com/stainless-sdks/unify-python.git
# install from PyPI
pip install unifygtm-sdk
```

> [!NOTE]
> Once this package is [published to PyPI](https://www.stainless.com/docs/guides/publish), this will become: `pip install unifygtm-sdk`

## Usage

The full API of this library can be found in [api.md](api.md).
Expand Down Expand Up @@ -75,8 +72,8 @@ By default, the async client uses `httpx` for HTTP requests. However, for improv
You can enable this by installing `aiohttp`:

```sh
# install from this staging repo
pip install 'unifygtm-sdk[aiohttp] @ git+ssh://git@github.com/stainless-sdks/unify-python.git'
# install from PyPI
pip install unifygtm-sdk[aiohttp]
```

Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:
Expand Down Expand Up @@ -267,9 +264,9 @@ object_ = response.parse() # get the object that `data.objects.list()` would ha
print(object_.data)
```

These methods return an [`APIResponse`](https://github.com/stainless-sdks/unify-python/tree/main/src/unify/_response.py) object.
These methods return an [`APIResponse`](https://github.com/unifygtm/sdk-python/tree/main/src/unify/_response.py) object.

The async client returns an [`AsyncAPIResponse`](https://github.com/stainless-sdks/unify-python/tree/main/src/unify/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
The async client returns an [`AsyncAPIResponse`](https://github.com/unifygtm/sdk-python/tree/main/src/unify/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.

#### `.with_streaming_response`

Expand Down Expand Up @@ -373,7 +370,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.

We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/unify-python/issues) with questions, bugs, or suggestions.
We are keen for your feedback; please open an [issue](https://www.github.com/unifygtm/sdk-python/issues) with questions, bugs, or suggestions.

### Determining the installed version

Expand Down
6 changes: 6 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Types:
from unify.types.data import (
UAddress,
UBoolean,
UCompanyAttributes,
UCountry,
UCurrency,
UDate,
Expand All @@ -88,14 +89,19 @@ from unify.types.data import (
UEmail,
UInteger,
UMultiselect,
UOpportunityAttributes,
UPersonAttributes,
UPhoneNumber,
URecord,
URecordAttributes,
UReferenceByID,
UReferenceByMatch,
UReferenceByUpsert,
USelect,
UText,
UURL,
UUuid,
UValue,
ValidationMode,
RecordCreateResponse,
RecordRetrieveResponse,
Expand Down
17 changes: 17 additions & 0 deletions bin/check-release-environment
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

errors=()

lenErrors=${#errors[@]}

if [[ lenErrors -gt 0 ]]; then
echo -e "Found the following errors in the release environment:\n"

for error in "${errors[@]}"; do
echo -e "- $error\n"
done

exit 1
fi

echo "The environment is ready to push releases!"
6 changes: 5 additions & 1 deletion bin/publish-pypi
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ set -eux
rm -rf dist
mkdir -p dist
uv build
uv publish --token=$PYPI_TOKEN
if [ -n "${PYPI_TOKEN:-}" ]; then
uv publish --token=$PYPI_TOKEN
else
uv publish
fi
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "unifygtm-sdk"
version = "0.0.1"
version = "0.1.0"
description = "The official Python library for the Unify API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down Expand Up @@ -37,8 +37,8 @@ classifiers = [
]

[project.urls]
Homepage = "https://github.com/stainless-sdks/unify-python"
Repository = "https://github.com/stainless-sdks/unify-python"
Homepage = "https://github.com/unifygtm/sdk-python"
Repository = "https://github.com/unifygtm/sdk-python"

[project.optional-dependencies]
aiohttp = ["aiohttp", "httpx_aiohttp>=0.1.9"]
Expand Down Expand Up @@ -112,7 +112,7 @@ 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/stainless-sdks/unify-python/tree/main/\g<2>)'
replacement = '[\1](https://github.com/unifygtm/sdk-python/tree/main/\g<2>)'

[tool.pytest.ini_options]
testpaths = ["tests"]
Expand Down
66 changes: 66 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"packages": {
".": {}
},
"$schema": "https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json",
"include-v-in-tag": true,
"include-component-in-tag": false,
"versioning": "prerelease",
"prerelease": true,
"bump-minor-pre-major": true,
"bump-patch-for-minor-pre-major": false,
"pull-request-header": "Automated Release PR",
"pull-request-title-pattern": "release: ${version}",
"changelog-sections": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "perf",
"section": "Performance Improvements"
},
{
"type": "revert",
"section": "Reverts"
},
{
"type": "chore",
"section": "Chores"
},
{
"type": "docs",
"section": "Documentation"
},
{
"type": "style",
"section": "Styles"
},
{
"type": "refactor",
"section": "Refactors"
},
{
"type": "test",
"section": "Tests",
"hidden": true
},
{
"type": "build",
"section": "Build System"
},
{
"type": "ci",
"section": "Continuous Integration",
"hidden": true
}
],
"release-type": "python",
"extra-files": [
"src/unify/_version.py"
]
}
56 changes: 53 additions & 3 deletions src/unify/_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import io
import os
import pathlib
from typing import overload
from typing_extensions import TypeGuard
from typing import Sequence, cast, overload
from typing_extensions import TypeVar, TypeGuard

import anyio

Expand All @@ -17,7 +17,9 @@
HttpxFileContent,
HttpxRequestFiles,
)
from ._utils import is_tuple_t, is_mapping_t, is_sequence_t
from ._utils import is_list, is_mapping, is_tuple_t, is_mapping_t, is_sequence_t

_T = TypeVar("_T")


def is_base64_file_input(obj: object) -> TypeGuard[Base64FileInput]:
Expand Down Expand Up @@ -121,3 +123,51 @@ async def async_read_file_content(file: FileContent) -> HttpxFileContent:
return await anyio.Path(file).read_bytes()

return file


def deepcopy_with_paths(item: _T, paths: Sequence[Sequence[str]]) -> _T:
"""Copy only the containers along the given paths.

Used to guard against mutation by extract_files without copying the entire structure.
Only dicts and lists that lie on a path are copied; everything else
is returned by reference.

For example, given paths=[["foo", "files", "file"]] and the structure:
{
"foo": {
"bar": {"baz": {}},
"files": {"file": <content>}
}
}
The root dict, "foo", and "files" are copied (they lie on the path).
"bar" and "baz" are returned by reference (off the path).
"""
return _deepcopy_with_paths(item, paths, 0)


def _deepcopy_with_paths(item: _T, paths: Sequence[Sequence[str]], index: int) -> _T:
if not paths:
return item
if is_mapping(item):
key_to_paths: dict[str, list[Sequence[str]]] = {}
for path in paths:
if index < len(path):
key_to_paths.setdefault(path[index], []).append(path)

# if no path continues through this mapping, it won't be mutated and copying it is redundant
if not key_to_paths:
return item

result = dict(item)
for key, subpaths in key_to_paths.items():
if key in result:
result[key] = _deepcopy_with_paths(result[key], subpaths, index + 1)
return cast(_T, result)
if is_list(item):
array_paths = [path for path in paths if index < len(path) and path[index] == "<array>"]

# if no path expects a list here, nothing will be mutated inside it - return by reference
if not array_paths:
return cast(_T, item)
return cast(_T, [_deepcopy_with_paths(entry, array_paths, index + 1) for entry in item])
return item
1 change: 0 additions & 1 deletion src/unify/_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
coerce_integer as coerce_integer,
file_from_path as file_from_path,
strip_not_given as strip_not_given,
deepcopy_minimal as deepcopy_minimal,
get_async_library as get_async_library,
maybe_coerce_float as maybe_coerce_float,
get_required_header as get_required_header,
Expand Down
Loading
Loading