Skip to content

release: 1.35.1 #102

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 16 commits into from
Dec 26, 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
2 changes: 2 additions & 0 deletions .github/workflows/create-releases.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Create releases
on:
schedule:
- cron: '0 5 * * *' # every day at 5am UTC
push:
branches:
- main
Expand Down
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.35.0"
".": "1.35.1"
}
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
# Changelog

## 1.35.1 (2023-12-26)

Full Changelog: [v1.35.0...v1.35.1](https://github.com/orbcorp/orb-python/compare/v1.35.0...v1.35.1)

### Bug Fixes

* use brackets instead of commas for array query params ([#116](https://github.com/orbcorp/orb-python/issues/116)) ([a03afeb](https://github.com/orbcorp/orb-python/commit/a03afeb4c13765e905a3e5fc8e52e1da4fa8e4be))


### Chores

* **ci:** run release workflow once per day ([#107](https://github.com/orbcorp/orb-python/issues/107)) ([8399dca](https://github.com/orbcorp/orb-python/commit/8399dcad701cac68076d88efba8aa2f6d456ad4b))
* **internal:** add bin script ([#113](https://github.com/orbcorp/orb-python/issues/113)) ([ed19a63](https://github.com/orbcorp/orb-python/commit/ed19a63151d3f4119fa70b68459242030a4ba199))
* **internal:** fix typos ([#111](https://github.com/orbcorp/orb-python/issues/111)) ([e2ba1db](https://github.com/orbcorp/orb-python/commit/e2ba1db59f6d8e86c625310d5017ece279788bd2))
* **internal:** minor utils restructuring ([#110](https://github.com/orbcorp/orb-python/issues/110)) ([1946480](https://github.com/orbcorp/orb-python/commit/19464809e1a6d4ba122b767ed59551ec0509503e))
* **internal:** updates to base client ([#108](https://github.com/orbcorp/orb-python/issues/108)) ([53ea238](https://github.com/orbcorp/orb-python/commit/53ea2380bb8280bd679255afed4300daeb1620ea))
* **internal:** use ruff instead of black for formatting ([#115](https://github.com/orbcorp/orb-python/issues/115)) ([ed83783](https://github.com/orbcorp/orb-python/commit/ed837839d28c1191bb4656577b8d80a411ce82dd))
* **package:** bump minimum typing-extensions to 4.7 ([#112](https://github.com/orbcorp/orb-python/issues/112)) ([440c756](https://github.com/orbcorp/orb-python/commit/440c756ffab480330f7a01dbbb129a26f41c1612))


### Documentation

* **api:** updates ([#109](https://github.com/orbcorp/orb-python/issues/109)) ([692c3e8](https://github.com/orbcorp/orb-python/commit/692c3e8ea49d3fe7dfc2f03d78be25cc2237fb9f))
* avoid normalizing trailing space ([#106](https://github.com/orbcorp/orb-python/issues/106)) ([09fd3f8](https://github.com/orbcorp/orb-python/commit/09fd3f8e37d3138bd32532aba6729e24b208684c))
* improve README timeout comment ([#101](https://github.com/orbcorp/orb-python/issues/101)) ([69a6970](https://github.com/orbcorp/orb-python/commit/69a6970e11ba88969a3c17dcd4374f8197b88dca))


### Refactors

* **client:** simplify cleanup ([#103](https://github.com/orbcorp/orb-python/issues/103)) ([54ac0dd](https://github.com/orbcorp/orb-python/commit/54ac0ddb1b703e011e84f184e6e90ee9f31e2055))
* remove unused model types used in params ([#105](https://github.com/orbcorp/orb-python/issues/105)) ([e18a59e](https://github.com/orbcorp/orb-python/commit/e18a59e47125aafb2e81f29f45fe9e866c738d28))
* simplify internal error handling ([#104](https://github.com/orbcorp/orb-python/issues/104)) ([cd0f847](https://github.com/orbcorp/orb-python/commit/cd0f8472457ac651c2fa44dc1e464cac78257c59))

## 1.35.0 (2023-12-11)

Full Changelog: [v1.34.1...v1.35.0](https://github.com/orbcorp/orb-python/compare/v1.34.1...v1.35.0)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ from orb import Orb

# Configure the default for all requests:
client = Orb(
# default is 60s
# 20 seconds (default is 1 minute)
timeout=20.0,
)

Expand Down
5 changes: 1 addition & 4 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,7 @@ Methods:
Types:

```python
from orb.types.customers import (
BalanceTransactionCreateResponse,
BalanceTransactionListResponse,
)
from orb.types.customers import BalanceTransactionCreateResponse, BalanceTransactionListResponse
```

Methods:
Expand Down
40 changes: 40 additions & 0 deletions bin/check-env-state.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""Script that exits 1 if the current environment is not
in sync with the `requirements-dev.lock` file.
"""

from pathlib import Path

import importlib_metadata


def should_run_sync() -> bool:
dev_lock = Path(__file__).parent.parent.joinpath("requirements-dev.lock")

for line in dev_lock.read_text().splitlines():
if not line or line.startswith("#") or line.startswith("-e"):
continue

dep, lock_version = line.split("==")

try:
version = importlib_metadata.version(dep)

if lock_version != version:
print(f"mismatch for {dep} current={version} lock={lock_version}")
return True
except Exception:
print(f"could not import {dep}")
return True

return False


def main() -> None:
if should_run_sync():
exit(1)
else:
exit(0)


if __name__ == "__main__":
main()
130 changes: 23 additions & 107 deletions bin/blacken-docs.py → bin/ruffen-docs.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# fork of https://github.com/asottile/blacken-docs implementing https://github.com/asottile/blacken-docs/issues/170
# fork of https://github.com/asottile/blacken-docs adapted for ruff
from __future__ import annotations

import re
import sys
import argparse
import textwrap
import contextlib
import subprocess
from typing import Match, Optional, Sequence, Generator, NamedTuple, cast

import black
from black.mode import TargetVersion
from black.const import DEFAULT_LINE_LENGTH

MD_RE = re.compile(
r"(?P<before>^(?P<indent> *)```\s*python\n)" r"(?P<code>.*?)" r"(?P<after>^(?P=indent)```\s*$)",
re.DOTALL | re.MULTILINE,
Expand All @@ -19,55 +17,12 @@
r"(?P<before>^(?P<indent> *)```\s*pycon\n)" r"(?P<code>.*?)" r"(?P<after>^(?P=indent)```.*$)",
re.DOTALL | re.MULTILINE,
)
RST_PY_LANGS = frozenset(("python", "py", "sage", "python3", "py3", "numpy"))
BLOCK_TYPES = "(code|code-block|sourcecode|ipython)"
DOCTEST_TYPES = "(testsetup|testcleanup|testcode)"
RST_RE = re.compile(
rf"(?P<before>"
rf"^(?P<indent> *)\.\. ("
rf"jupyter-execute::|"
rf"{BLOCK_TYPES}:: (?P<lang>\w+)|"
rf"{DOCTEST_TYPES}::.*"
rf")\n"
rf"((?P=indent) +:.*\n)*"
rf"\n*"
rf")"
rf"(?P<code>(^((?P=indent) +.*)?\n)+)",
re.MULTILINE,
)
RST_PYCON_RE = re.compile(
r"(?P<before>"
r"(?P<indent> *)\.\. ((code|code-block):: pycon|doctest::.*)\n"
r"((?P=indent) +:.*\n)*"
r"\n*"
r")"
r"(?P<code>(^((?P=indent) +.*)?(\n|$))+)",
re.MULTILINE,
)
PYCON_PREFIX = ">>> "
PYCON_CONTINUATION_PREFIX = "..."
PYCON_CONTINUATION_RE = re.compile(
rf"^{re.escape(PYCON_CONTINUATION_PREFIX)}( |$)",
)
LATEX_RE = re.compile(
r"(?P<before>^(?P<indent> *)\\begin{minted}{python}\n)"
r"(?P<code>.*?)"
r"(?P<after>^(?P=indent)\\end{minted}\s*$)",
re.DOTALL | re.MULTILINE,
)
LATEX_PYCON_RE = re.compile(
r"(?P<before>^(?P<indent> *)\\begin{minted}{pycon}\n)" r"(?P<code>.*?)" r"(?P<after>^(?P=indent)\\end{minted}\s*$)",
re.DOTALL | re.MULTILINE,
)
PYTHONTEX_LANG = r"(?P<lang>pyblock|pycode|pyconsole|pyverbatim)"
PYTHONTEX_RE = re.compile(
rf"(?P<before>^(?P<indent> *)\\begin{{{PYTHONTEX_LANG}}}\n)"
rf"(?P<code>.*?)"
rf"(?P<after>^(?P=indent)\\end{{(?P=lang)}}\s*$)",
re.DOTALL | re.MULTILINE,
)
INDENT_RE = re.compile("^ +(?=[^ ])", re.MULTILINE)
TRAILING_NL_RE = re.compile(r"\n+\Z", re.MULTILINE)
DEFAULT_LINE_LENGTH = 100


class CodeBlockError(NamedTuple):
Expand All @@ -77,7 +32,6 @@ class CodeBlockError(NamedTuple):

def format_str(
src: str,
black_mode: black.FileMode,
) -> tuple[str, Sequence[CodeBlockError]]:
errors: list[CodeBlockError] = []

Expand All @@ -91,24 +45,10 @@ def _collect_error(match: Match[str]) -> Generator[None, None, None]:
def _md_match(match: Match[str]) -> str:
code = textwrap.dedent(match["code"])
with _collect_error(match):
code = black.format_str(code, mode=black_mode)
code = format_code_block(code)
code = textwrap.indent(code, match["indent"])
return f'{match["before"]}{code}{match["after"]}'

def _rst_match(match: Match[str]) -> str:
lang = match["lang"]
if lang is not None and lang not in RST_PY_LANGS:
return match[0]
min_indent = min(INDENT_RE.findall(match["code"]))
trailing_ws_match = TRAILING_NL_RE.search(match["code"])
assert trailing_ws_match
trailing_ws = trailing_ws_match.group()
code = textwrap.dedent(match["code"])
with _collect_error(match):
code = black.format_str(code, mode=black_mode)
code = textwrap.indent(code, min_indent)
return f'{match["before"]}{code.rstrip()}{trailing_ws}'

def _pycon_match(match: Match[str]) -> str:
code = ""
fragment = cast(Optional[str], None)
Expand All @@ -119,7 +59,7 @@ def finish_fragment() -> None:

if fragment is not None:
with _collect_error(match):
fragment = black.format_str(fragment, mode=black_mode)
fragment = format_code_block(fragment)
fragment_lines = fragment.splitlines()
code += f"{PYCON_PREFIX}{fragment_lines[0]}\n"
for line in fragment_lines[1:]:
Expand Down Expand Up @@ -159,42 +99,33 @@ def _md_pycon_match(match: Match[str]) -> str:
code = textwrap.indent(code, match["indent"])
return f'{match["before"]}{code}{match["after"]}'

def _rst_pycon_match(match: Match[str]) -> str:
code = _pycon_match(match)
min_indent = min(INDENT_RE.findall(match["code"]))
code = textwrap.indent(code, min_indent)
return f'{match["before"]}{code}'

def _latex_match(match: Match[str]) -> str:
code = textwrap.dedent(match["code"])
with _collect_error(match):
code = black.format_str(code, mode=black_mode)
code = textwrap.indent(code, match["indent"])
return f'{match["before"]}{code}{match["after"]}'

def _latex_pycon_match(match: Match[str]) -> str:
code = _pycon_match(match)
code = textwrap.indent(code, match["indent"])
return f'{match["before"]}{code}{match["after"]}'

src = MD_RE.sub(_md_match, src)
src = MD_PYCON_RE.sub(_md_pycon_match, src)
src = RST_RE.sub(_rst_match, src)
src = RST_PYCON_RE.sub(_rst_pycon_match, src)
src = LATEX_RE.sub(_latex_match, src)
src = LATEX_PYCON_RE.sub(_latex_pycon_match, src)
src = PYTHONTEX_RE.sub(_latex_match, src)
return src, errors


def format_code_block(code: str) -> str:
return subprocess.check_output(
[
sys.executable,
"-m",
"ruff",
"format",
"--stdin-filename=script.py",
f"--line-length={DEFAULT_LINE_LENGTH}",
],
encoding="utf-8",
input=code,
)


def format_file(
filename: str,
black_mode: black.FileMode,
skip_errors: bool,
) -> int:
with open(filename, encoding="UTF-8") as f:
contents = f.read()
new_contents, errors = format_str(contents, black_mode)
new_contents, errors = format_str(contents)
for error in errors:
lineno = contents[: error.offset].count("\n") + 1
print(f"{filename}:{lineno}: code block parse error {error.exc}")
Expand All @@ -217,15 +148,6 @@ def main(argv: Sequence[str] | None = None) -> int:
type=int,
default=DEFAULT_LINE_LENGTH,
)
parser.add_argument(
"-t",
"--target-version",
action="append",
type=lambda v: TargetVersion[v.upper()],
default=[],
help=f"choices: {[v.name.lower() for v in TargetVersion]}",
dest="target_versions",
)
parser.add_argument(
"-S",
"--skip-string-normalization",
Expand All @@ -235,15 +157,9 @@ def main(argv: Sequence[str] | None = None) -> int:
parser.add_argument("filenames", nargs="*")
args = parser.parse_args(argv)

black_mode = black.FileMode(
target_versions=set(args.target_versions),
line_length=args.line_length,
string_normalization=not args.skip_string_normalization,
)

retv = 0
for filename in args.filenames:
retv |= format_file(filename, black_mode, skip_errors=args.skip_errors)
retv |= format_file(filename, skip_errors=args.skip_errors)
return retv


Expand Down
19 changes: 11 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "orb-billing"
version = "1.35.0"
version = "1.35.1"
description = "The official Python library for the orb API"
readme = "README.md"
license = "Apache-2.0"
Expand All @@ -10,7 +10,7 @@ authors = [
dependencies = [
"httpx>=0.23.0, <1",
"pydantic>=1.9.0, <3",
"typing-extensions>=4.5, <5",
"typing-extensions>=4.7, <5",
"anyio>=3.5.0, <5",
"distro>=1.7.0, <2",
"sniffio",
Expand Down Expand Up @@ -49,7 +49,6 @@ managed = true
dev-dependencies = [
"pyright",
"mypy",
"black",
"respx",
"pytest",
"pytest-asyncio",
Expand All @@ -58,30 +57,32 @@ dev-dependencies = [
"time-machine",
"nox",
"dirty-equals>=0.6.0",
"importlib-metadata>=6.7.0",

]

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

"check:ruff" = "ruff ."
"fix:ruff" = "ruff --fix ."

typecheck = { chain = [
"typecheck:pyright",
"typecheck:mypy"
]}
"typecheck:pyright" = "pyright"
"typecheck:verify-types" = "pyright --verifytypes orb --ignoreexternal"
"typecheck:mypy" = "mypy --enable-incomplete-feature=Unpack ."
"typecheck:mypy" = "mypy ."

[build-system]
requires = ["hatchling"]
Expand Down Expand Up @@ -159,6 +160,8 @@ unfixable = [
]
ignore-init-module-imports = true

[tool.ruff.format]
docstring-code-format = true

[tool.ruff.per-file-ignores]
"bin/**.py" = ["T201", "T203"]
Expand Down
Loading