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: 0.5.0 #195

Merged
merged 5 commits into from
Oct 18, 2023
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
12 changes: 7 additions & 5 deletions .github/workflows/create-releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,18 @@ jobs:
repo: ${{ github.event.repository.full_name }}
stainless-api-key: ${{ secrets.STAINLESS_API_KEY }}

- name: Set up Python
- name: Install Rye
if: ${{ steps.release.outputs.releases_created }}
uses: actions/setup-python@v4
with:
python-version: '3.7'
run: |
curl -sSf https://rye-up.com/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_VERSION: 0.15.2
RYE_INSTALL_OPTION: "--yes"

- name: Publish to PyPI
if: ${{ steps.release.outputs.releases_created }}
run: |
pipx install poetry
bash ./bin/publish-pypi
env:
PYPI_TOKEN: ${{ secrets.ANTHROPIC_PYPI_TOKEN }}
12 changes: 7 additions & 5 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.7'
- name: Install Rye
run: |
curl -sSf https://rye-up.com/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_VERSION: 0.15.2
RYE_INSTALL_OPTION: "--yes"

- name: Publish to PyPI
run: |
pipx install poetry
bash ./bin/publish-pypi
env:
PYPI_TOKEN: ${{ secrets.ANTHROPIC_PYPI_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ __pycache__

dist

.venv
.idea

.env
codegen.log
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.4.1"
".": "0.5.0"
}
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 0.5.0 (2023-10-18)

Full Changelog: [v0.4.1...v0.5.0](https://github.com/anthropics/anthropic-sdk-python/compare/v0.4.1...v0.5.0)

### Features

* **client:** support passing httpx.URL instances to base_url ([#197](https://github.com/anthropics/anthropic-sdk-python/issues/197)) ([fe61308](https://github.com/anthropics/anthropic-sdk-python/commit/fe61308baa7d11993e72b3a282633a24fb4e61e4))


### Chores

* **internal:** improve publish script ([#196](https://github.com/anthropics/anthropic-sdk-python/issues/196)) ([7c92b90](https://github.com/anthropics/anthropic-sdk-python/commit/7c92b90864f9510e7cbb68c6b703eec7fd4b7b28))
* **internal:** migrate from Poetry to Rye ([#194](https://github.com/anthropics/anthropic-sdk-python/issues/194)) ([1dd605e](https://github.com/anthropics/anthropic-sdk-python/commit/1dd605e7daf6f8542cb0ff5f5af4f161153f239a))
* **internal:** update gitignore ([#198](https://github.com/anthropics/anthropic-sdk-python/issues/198)) ([4c210b7](https://github.com/anthropics/anthropic-sdk-python/commit/4c210b75ce9fee9a781fbcbab8711409de2d9eea))

## 0.4.1 (2023-10-16)

Full Changelog: [v0.4.0...v0.4.1](https://github.com/anthropics/anthropic-sdk-python/compare/v0.4.0...v0.4.1)
Expand Down
5 changes: 3 additions & 2 deletions bin/publish-pypi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env bash

set -eux
poetry config pypi-token.pypi $PYPI_TOKEN
poetry publish --build
mkdir -p dist
rye build --clean
rye publish --yes --token=$PYPI_TOKEN
2 changes: 1 addition & 1 deletion bin/test
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

bin/check-test-server && poetry run pytest "$@"
bin/check-test-server && rye run pytest "$@"
9 changes: 3 additions & 6 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import nox
import nox_poetry


@nox_poetry.session(reuse_venv=True, name="test-pydantic-v1")
@nox.session(reuse_venv=True, name="test-pydantic-v1")
def test_pydantic_v1(session: nox.Session) -> None:
session.run_always("poetry", "install", external=True)

# https://github.com/cjolowicz/nox-poetry/issues/1116
session._session.run("python", "-m", "pip", "install", "pydantic<2", external=True) # type: ignore
session.install("-r", "requirements-dev.lock")
session.install("pydantic<2")

session.run("pytest", "--showlocals", "--ignore=tests/functional", *session.posargs)
1,448 changes: 0 additions & 1,448 deletions poetry.lock

This file was deleted.

82 changes: 54 additions & 28 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,43 +1,69 @@
[tool.poetry]
[project]
name = "anthropic"
version = "0.4.1"
version = "0.5.0"
description = "Client library for the anthropic API"
readme = "README.md"
authors = ["Anthropic <[email protected]>"]
license = "MIT"
repository = "https://github.com/anthropics/anthropic-sdk-python"
packages = [
{ include = "anthropic", from = "src" }
authors = [
{ name = "Anthropic", email = "[email protected]" },
]
dependencies = [
"httpx>=0.23.0, <1",
"pydantic>=1.9.0, <3",
"typing-extensions>=4.5, <5",
"anyio>=3.5.0, <4",
"distro>=1.7.0, <2",
"tokenizers >= 0.13.0"
]
requires-python = ">= 3.7"


[tool.poetry.dependencies]
python = "^3.7"
httpx = ">= 0.23.0, < 1"
pydantic = ">= 1.9.0, < 3"
typing-extensions = ">= 4.5, < 5"
anyio = ">= 3.5.0, < 4"
distro = ">= 1.7.0, < 2"
tokenizers = ">= 0.13.0"

[project.urls]
Homepage = "https://github.com/anthropics/anthropic-sdk-python"
Repository = "https://github.com/anthropics/anthropic-sdk-python"

[tool.poetry.group.dev.dependencies]
pyright = "1.1.326"
mypy = "1.4.1"
black = "23.3.0"
respx = "0.19.2"
pytest = "7.1.1"
pytest-asyncio = "0.21.1"
ruff = "0.0.282"
isort = "5.10.1"
time-machine = "^2.9.0"
nox = "^2023.4.22"
nox-poetry = "^1.0.3"


[tool.rye]
managed = true
dev-dependencies = [
"pyright==1.1.326",
"mypy==1.4.1",
"black==23.3.0",
"respx==0.19.2",
"pytest==7.1.1",
"pytest-asyncio==0.21.1",
"ruff==0.0.282",
"isort==5.10.1",
"time-machine==2.9.0",
"nox==2023.4.22",

]

[tool.rye.scripts]
format = { chain = [
"format:black",
"format:docs",
"format:ruff",
"format:isort",
]}
"format:black" = "black ."
"format:docs" = "python bin/blacken-docs.py README.md api.md"
"format:ruff" = "ruff --fix ."
"format:isort" = "isort ."

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build]
include = [
"src/*"
]

[tool.hatch.build.targets.wheel]
packages = ["src/anthropic"]

[tool.black]
line-length = 120
Expand Down
61 changes: 61 additions & 0 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: true

-e file:.
annotated-types==0.6.0
anyio==3.7.1
argcomplete==3.1.2
attrs==23.1.0
black==23.3.0
certifi==2023.7.22
charset-normalizer==3.3.0
click==8.1.7
colorlog==6.7.0
distlib==0.3.7
distro==1.8.0
exceptiongroup==1.1.3
filelock==3.12.4
fsspec==2023.9.2
h11==0.12.0
httpcore==0.15.0
httpx==0.23.0
huggingface-hub==0.16.4
idna==3.4
iniconfig==2.0.0
isort==5.10.1
mypy==1.4.1
mypy-extensions==1.0.0
nodeenv==1.8.0
nox==2023.4.22
packaging==23.2
pathspec==0.11.2
platformdirs==3.11.0
pluggy==1.3.0
py==1.11.0
pydantic==2.4.2
pydantic-core==2.10.1
pyright==1.1.326
pytest==7.1.1
pytest-asyncio==0.21.1
python-dateutil==2.8.2
pyyaml==6.0.1
requests==2.31.0
respx==0.19.2
rfc3986==1.5.0
ruff==0.0.282
six==1.16.0
sniffio==1.3.0
time-machine==2.9.0
tokenizers==0.14.0
tomli==2.0.1
tqdm==4.66.1
typing-extensions==4.8.0
urllib3==2.0.6
virtualenv==20.24.5
# The following packages are considered to be unsafe in a requirements file:
setuptools==68.2.2
33 changes: 33 additions & 0 deletions requirements.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: true

-e file:.
annotated-types==0.6.0
anyio==3.7.1
certifi==2023.7.22
charset-normalizer==3.3.0
distro==1.8.0
exceptiongroup==1.1.3
filelock==3.12.4
fsspec==2023.9.2
h11==0.12.0
httpcore==0.15.0
httpx==0.23.0
huggingface-hub==0.16.4
idna==3.4
packaging==23.2
pydantic==2.4.2
pydantic-core==2.10.1
pyyaml==6.0.1
requests==2.31.0
rfc3986==1.5.0
sniffio==1.3.0
tokenizers==0.14.0
tqdm==4.66.1
typing-extensions==4.8.0
urllib3==2.0.6
6 changes: 3 additions & 3 deletions src/anthropic/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def __init__(
self,
*,
version: str,
base_url: str,
base_url: str | URL,
_strict_response_validation: bool,
max_retries: int = DEFAULT_MAX_RETRIES,
timeout: float | Timeout | None = DEFAULT_TIMEOUT,
Expand Down Expand Up @@ -739,7 +739,7 @@ def __init__(
self,
*,
version: str,
base_url: str,
base_url: str | URL,
max_retries: int = DEFAULT_MAX_RETRIES,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
transport: Transport | None = None,
Expand Down Expand Up @@ -1145,7 +1145,7 @@ def __init__(
self,
*,
version: str,
base_url: str,
base_url: str | URL,
_strict_response_validation: bool,
max_retries: int = DEFAULT_MAX_RETRIES,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
Expand Down
10 changes: 5 additions & 5 deletions src/anthropic/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import os
import asyncio
from typing import Union, Mapping, Optional
from typing import Union, Mapping

import httpx
from tokenizers import Tokenizer # type: ignore[import]
Expand Down Expand Up @@ -64,7 +64,7 @@ def __init__(
*,
api_key: str | None = None,
auth_token: str | None = None,
base_url: Optional[str] = None,
base_url: str | httpx.URL | None = None,
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
max_retries: int = DEFAULT_MAX_RETRIES,
default_headers: Mapping[str, str] | None = None,
Expand Down Expand Up @@ -176,7 +176,7 @@ def copy(
*,
api_key: str | None = None,
auth_token: str | None = None,
base_url: str | None = None,
base_url: str | httpx.URL | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
http_client: httpx.Client | None = None,
connection_pool_limits: httpx.Limits | None = None,
Expand Down Expand Up @@ -316,7 +316,7 @@ def __init__(
*,
api_key: str | None = None,
auth_token: str | None = None,
base_url: Optional[str] = None,
base_url: str | httpx.URL | None = None,
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
max_retries: int = DEFAULT_MAX_RETRIES,
default_headers: Mapping[str, str] | None = None,
Expand Down Expand Up @@ -428,7 +428,7 @@ def copy(
*,
api_key: str | None = None,
auth_token: str | None = None,
base_url: str | None = None,
base_url: str | httpx.URL | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
http_client: httpx.AsyncClient | None = None,
connection_pool_limits: httpx.Limits | None = None,
Expand Down
3 changes: 1 addition & 2 deletions src/anthropic/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import pydantic
import pydantic.generics
from pydantic import Extra
from pydantic.fields import FieldInfo

from ._types import (
Expand Down Expand Up @@ -56,7 +55,7 @@ def model_fields_set(self) -> set[str]:
return self.__fields_set__ # type: ignore

class Config(pydantic.BaseConfig): # pyright: ignore[reportDeprecated]
extra: Any = Extra.allow # type: ignore
extra: Any = pydantic.Extra.allow # type: ignore

def __str__(self) -> str:
# mypy complains about an invalid self arg
Expand Down
Loading