Skip to content

Commit

Permalink
chore(internal): codegen related update (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and Stainless Bot committed Aug 26, 2024
1 parent d860183 commit 4a94475
Show file tree
Hide file tree
Showing 27 changed files with 216 additions and 168 deletions.
18 changes: 11 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,12 @@ format = { chain = [
"lint" = { chain = [
"check:ruff",
"typecheck",
"check:importable",
]}
"check:ruff" = "ruff ."
"fix:ruff" = "ruff --fix ."
"check:ruff" = "ruff check ."
"fix:ruff" = "ruff check --fix ."

"check:importable" = "python -c 'import groq'"

typecheck = { chain = [
"typecheck:pyright",
Expand Down Expand Up @@ -162,6 +165,11 @@ reportPrivateUsage = false
line-length = 120
output-format = "grouped"
target-version = "py37"

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

[tool.ruff.lint]
select = [
# isort
"I",
Expand Down Expand Up @@ -190,10 +198,6 @@ unfixable = [
"T201",
"T203",
]
ignore-init-module-imports = true

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

[tool.ruff.lint.flake8-tidy-imports.banned-api]
"functools.lru_cache".msg = "This function does not retain type information for the wrapped function's arguments; The `lru_cache` function from `_utils` should be used instead"
Expand All @@ -205,7 +209,7 @@ combine-as-imports = true
extra-standard-library = ["typing_extensions"]
known-first-party = ["groq", "tests"]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"bin/**.py" = ["T201", "T203"]
"scripts/**.py" = ["T201", "T203"]
"tests/**.py" = ["T201", "T203"]
Expand Down
4 changes: 2 additions & 2 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pydantic-core==2.18.2
# via pydantic
pygments==2.18.0
# via rich
pyright==1.1.364
pyright==1.1.374
pytest==7.1.1
# via pytest-asyncio
pytest-asyncio==0.21.1
Expand All @@ -80,7 +80,7 @@ pytz==2023.3.post1
# via dirty-equals
respx==0.20.2
rich==13.7.1
ruff==0.1.9
ruff==0.5.6
setuptools==68.2.2
# via nodeenv
six==1.16.0
Expand Down
4 changes: 2 additions & 2 deletions scripts/mock
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ echo "==> Starting mock server with URL ${URL}"

# Run prism mock on the given spec
if [ "$1" == "--daemon" ]; then
npm exec --package=@stainless-api/prism-cli@5.8.4 -- prism mock "$URL" &> .prism.log &
npm exec --package=@stainless-api/prism-cli@5.8.5 -- prism mock "$URL" &> .prism.log &

# Wait for server to come online
echo -n "Waiting for server"
Expand All @@ -37,5 +37,5 @@ if [ "$1" == "--daemon" ]; then

echo
else
npm exec --package=@stainless-api/prism-cli@5.8.4 -- prism mock "$URL"
npm exec --package=@stainless-api/prism-cli@5.8.5 -- prism mock "$URL"
fi
71 changes: 29 additions & 42 deletions src/groq/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,14 @@ def __init__(
self,
*,
url: URL,
) -> None:
...
) -> None: ...

@overload
def __init__(
self,
*,
params: Query,
) -> None:
...
) -> None: ...

def __init__(
self,
Expand Down Expand Up @@ -166,8 +164,7 @@ def has_next_page(self) -> bool:
return False
return self.next_page_info() is not None

def next_page_info(self) -> Optional[PageInfo]:
...
def next_page_info(self) -> Optional[PageInfo]: ...

def _get_page_items(self) -> Iterable[_T]: # type: ignore[empty-body]
...
Expand Down Expand Up @@ -903,8 +900,7 @@ def request(
*,
stream: Literal[True],
stream_cls: Type[_StreamT],
) -> _StreamT:
...
) -> _StreamT: ...

@overload
def request(
Expand All @@ -914,8 +910,7 @@ def request(
remaining_retries: Optional[int] = None,
*,
stream: Literal[False] = False,
) -> ResponseT:
...
) -> ResponseT: ...

@overload
def request(
Expand All @@ -926,8 +921,7 @@ def request(
*,
stream: bool = False,
stream_cls: Type[_StreamT] | None = None,
) -> ResponseT | _StreamT:
...
) -> ResponseT | _StreamT: ...

def request(
self,
Expand Down Expand Up @@ -1049,6 +1043,7 @@ def _request(
response=response,
stream=stream,
stream_cls=stream_cls,
retries_taken=options.get_max_retries(self.max_retries) - retries,
)

def _retry_request(
Expand Down Expand Up @@ -1090,6 +1085,7 @@ def _process_response(
response: httpx.Response,
stream: bool,
stream_cls: type[Stream[Any]] | type[AsyncStream[Any]] | None,
retries_taken: int = 0,
) -> ResponseT:
origin = get_origin(cast_to) or cast_to

Expand All @@ -1107,6 +1103,7 @@ def _process_response(
stream=stream,
stream_cls=stream_cls,
options=options,
retries_taken=retries_taken,
),
)

Expand All @@ -1120,6 +1117,7 @@ def _process_response(
stream=stream,
stream_cls=stream_cls,
options=options,
retries_taken=retries_taken,
)
if bool(response.request.headers.get(RAW_RESPONSE_HEADER)):
return cast(ResponseT, api_response)
Expand Down Expand Up @@ -1152,8 +1150,7 @@ def get(
cast_to: Type[ResponseT],
options: RequestOptions = {},
stream: Literal[False] = False,
) -> ResponseT:
...
) -> ResponseT: ...

@overload
def get(
Expand All @@ -1164,8 +1161,7 @@ def get(
options: RequestOptions = {},
stream: Literal[True],
stream_cls: type[_StreamT],
) -> _StreamT:
...
) -> _StreamT: ...

@overload
def get(
Expand All @@ -1176,8 +1172,7 @@ def get(
options: RequestOptions = {},
stream: bool,
stream_cls: type[_StreamT] | None = None,
) -> ResponseT | _StreamT:
...
) -> ResponseT | _StreamT: ...

def get(
self,
Expand All @@ -1203,8 +1198,7 @@ def post(
options: RequestOptions = {},
files: RequestFiles | None = None,
stream: Literal[False] = False,
) -> ResponseT:
...
) -> ResponseT: ...

@overload
def post(
Expand All @@ -1217,8 +1211,7 @@ def post(
files: RequestFiles | None = None,
stream: Literal[True],
stream_cls: type[_StreamT],
) -> _StreamT:
...
) -> _StreamT: ...

@overload
def post(
Expand All @@ -1231,8 +1224,7 @@ def post(
files: RequestFiles | None = None,
stream: bool,
stream_cls: type[_StreamT] | None = None,
) -> ResponseT | _StreamT:
...
) -> ResponseT | _StreamT: ...

def post(
self,
Expand Down Expand Up @@ -1465,8 +1457,7 @@ async def request(
*,
stream: Literal[False] = False,
remaining_retries: Optional[int] = None,
) -> ResponseT:
...
) -> ResponseT: ...

@overload
async def request(
Expand All @@ -1477,8 +1468,7 @@ async def request(
stream: Literal[True],
stream_cls: type[_AsyncStreamT],
remaining_retries: Optional[int] = None,
) -> _AsyncStreamT:
...
) -> _AsyncStreamT: ...

@overload
async def request(
Expand All @@ -1489,8 +1479,7 @@ async def request(
stream: bool,
stream_cls: type[_AsyncStreamT] | None = None,
remaining_retries: Optional[int] = None,
) -> ResponseT | _AsyncStreamT:
...
) -> ResponseT | _AsyncStreamT: ...

async def request(
self,
Expand Down Expand Up @@ -1610,6 +1599,7 @@ async def _request(
response=response,
stream=stream,
stream_cls=stream_cls,
retries_taken=options.get_max_retries(self.max_retries) - retries,
)

async def _retry_request(
Expand Down Expand Up @@ -1649,6 +1639,7 @@ async def _process_response(
response: httpx.Response,
stream: bool,
stream_cls: type[Stream[Any]] | type[AsyncStream[Any]] | None,
retries_taken: int = 0,
) -> ResponseT:
origin = get_origin(cast_to) or cast_to

Expand All @@ -1666,6 +1657,7 @@ async def _process_response(
stream=stream,
stream_cls=stream_cls,
options=options,
retries_taken=retries_taken,
),
)

Expand All @@ -1679,6 +1671,7 @@ async def _process_response(
stream=stream,
stream_cls=stream_cls,
options=options,
retries_taken=retries_taken,
)
if bool(response.request.headers.get(RAW_RESPONSE_HEADER)):
return cast(ResponseT, api_response)
Expand All @@ -1701,8 +1694,7 @@ async def get(
cast_to: Type[ResponseT],
options: RequestOptions = {},
stream: Literal[False] = False,
) -> ResponseT:
...
) -> ResponseT: ...

@overload
async def get(
Expand All @@ -1713,8 +1705,7 @@ async def get(
options: RequestOptions = {},
stream: Literal[True],
stream_cls: type[_AsyncStreamT],
) -> _AsyncStreamT:
...
) -> _AsyncStreamT: ...

@overload
async def get(
Expand All @@ -1725,8 +1716,7 @@ async def get(
options: RequestOptions = {},
stream: bool,
stream_cls: type[_AsyncStreamT] | None = None,
) -> ResponseT | _AsyncStreamT:
...
) -> ResponseT | _AsyncStreamT: ...

async def get(
self,
Expand All @@ -1750,8 +1740,7 @@ async def post(
files: RequestFiles | None = None,
options: RequestOptions = {},
stream: Literal[False] = False,
) -> ResponseT:
...
) -> ResponseT: ...

@overload
async def post(
Expand All @@ -1764,8 +1753,7 @@ async def post(
options: RequestOptions = {},
stream: Literal[True],
stream_cls: type[_AsyncStreamT],
) -> _AsyncStreamT:
...
) -> _AsyncStreamT: ...

@overload
async def post(
Expand All @@ -1778,8 +1766,7 @@ async def post(
options: RequestOptions = {},
stream: bool,
stream_cls: type[_AsyncStreamT] | None = None,
) -> ResponseT | _AsyncStreamT:
...
) -> ResponseT | _AsyncStreamT: ...

async def post(
self,
Expand Down
Loading

0 comments on commit 4a94475

Please sign in to comment.