feat(api): OpenAPI spec update via Stainless API (#1255)

This commit is contained in:
stainless-app[bot] 2024-08-06 10:46:04 +00:00 committed by stainless-bot
parent d598a2c31a
commit 40b04cf904
28 changed files with 96 additions and 160 deletions

View file

@ -1,2 +1,2 @@
configured_endpoints: 1263
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-96b2fae0a8772e1f531c396d59d7ec872b56f1045226193e5db34c0a87f52c4c.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b21bdf2ca45a1764221729ac3732b249ff8afb8034f90ad25ad423f14deb61de.yml

View file

@ -77,8 +77,8 @@ format = { chain = [
"check:ruff",
"typecheck",
]}
"check:ruff" = "ruff ."
"fix:ruff" = "ruff --fix ."
"check:ruff" = "ruff check ."
"fix:ruff" = "ruff check --fix ."
typecheck = { chain = [
"typecheck:pyright",
@ -163,6 +163,11 @@ reportOverlappingOverload = false
line-length = 120
output-format = "grouped"
target-version = "py37"
[tool.ruff.format]
docstring-code-format = true
[tool.ruff.lint]
select = [
# isort
"I",
@ -193,9 +198,6 @@ unfixable = [
]
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"

View file

@ -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

View file

@ -124,16 +124,14 @@ class PageInfo:
self,
*,
url: URL,
) -> None:
...
) -> None: ...
@overload
def __init__(
self,
*,
params: Query,
) -> None:
...
) -> None: ...
def __init__(
self,
@ -166,8 +164,7 @@ class BasePage(GenericModel, Generic[_T]):
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]
...
@ -903,8 +900,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
*,
stream: Literal[True],
stream_cls: Type[_StreamT],
) -> _StreamT:
...
) -> _StreamT: ...
@overload
def request(
@ -914,8 +910,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
remaining_retries: Optional[int] = None,
*,
stream: Literal[False] = False,
) -> ResponseT:
...
) -> ResponseT: ...
@overload
def request(
@ -926,8 +921,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
*,
stream: bool = False,
stream_cls: Type[_StreamT] | None = None,
) -> ResponseT | _StreamT:
...
) -> ResponseT | _StreamT: ...
def request(
self,
@ -1156,8 +1150,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
cast_to: Type[ResponseT],
options: RequestOptions = {},
stream: Literal[False] = False,
) -> ResponseT:
...
) -> ResponseT: ...
@overload
def get(
@ -1168,8 +1161,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
options: RequestOptions = {},
stream: Literal[True],
stream_cls: type[_StreamT],
) -> _StreamT:
...
) -> _StreamT: ...
@overload
def get(
@ -1180,8 +1172,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
options: RequestOptions = {},
stream: bool,
stream_cls: type[_StreamT] | None = None,
) -> ResponseT | _StreamT:
...
) -> ResponseT | _StreamT: ...
def get(
self,
@ -1207,8 +1198,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
options: RequestOptions = {},
files: RequestFiles | None = None,
stream: Literal[False] = False,
) -> ResponseT:
...
) -> ResponseT: ...
@overload
def post(
@ -1221,8 +1211,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
files: RequestFiles | None = None,
stream: Literal[True],
stream_cls: type[_StreamT],
) -> _StreamT:
...
) -> _StreamT: ...
@overload
def post(
@ -1235,8 +1224,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
files: RequestFiles | None = None,
stream: bool,
stream_cls: type[_StreamT] | None = None,
) -> ResponseT | _StreamT:
...
) -> ResponseT | _StreamT: ...
def post(
self,
@ -1469,8 +1457,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
*,
stream: Literal[False] = False,
remaining_retries: Optional[int] = None,
) -> ResponseT:
...
) -> ResponseT: ...
@overload
async def request(
@ -1481,8 +1468,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
stream: Literal[True],
stream_cls: type[_AsyncStreamT],
remaining_retries: Optional[int] = None,
) -> _AsyncStreamT:
...
) -> _AsyncStreamT: ...
@overload
async def request(
@ -1493,8 +1479,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
stream: bool,
stream_cls: type[_AsyncStreamT] | None = None,
remaining_retries: Optional[int] = None,
) -> ResponseT | _AsyncStreamT:
...
) -> ResponseT | _AsyncStreamT: ...
async def request(
self,
@ -1709,8 +1694,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
cast_to: Type[ResponseT],
options: RequestOptions = {},
stream: Literal[False] = False,
) -> ResponseT:
...
) -> ResponseT: ...
@overload
async def get(
@ -1721,8 +1705,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
options: RequestOptions = {},
stream: Literal[True],
stream_cls: type[_AsyncStreamT],
) -> _AsyncStreamT:
...
) -> _AsyncStreamT: ...
@overload
async def get(
@ -1733,8 +1716,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
options: RequestOptions = {},
stream: bool,
stream_cls: type[_AsyncStreamT] | None = None,
) -> ResponseT | _AsyncStreamT:
...
) -> ResponseT | _AsyncStreamT: ...
async def get(
self,
@ -1758,8 +1740,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
files: RequestFiles | None = None,
options: RequestOptions = {},
stream: Literal[False] = False,
) -> ResponseT:
...
) -> ResponseT: ...
@overload
async def post(
@ -1772,8 +1753,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
options: RequestOptions = {},
stream: Literal[True],
stream_cls: type[_AsyncStreamT],
) -> _AsyncStreamT:
...
) -> _AsyncStreamT: ...
@overload
async def post(
@ -1786,8 +1766,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
options: RequestOptions = {},
stream: bool,
stream_cls: type[_AsyncStreamT] | None = None,
) -> ResponseT | _AsyncStreamT:
...
) -> ResponseT | _AsyncStreamT: ...
async def post(
self,

View file

@ -159,22 +159,19 @@ def model_parse(model: type[_ModelT], data: Any) -> _ModelT:
# generic models
if TYPE_CHECKING:
class GenericModel(pydantic.BaseModel):
...
class GenericModel(pydantic.BaseModel): ...
else:
if PYDANTIC_V2:
# there no longer needs to be a distinction in v2 but
# we still have to create our own subclass to avoid
# inconsistent MRO ordering errors
class GenericModel(pydantic.BaseModel):
...
class GenericModel(pydantic.BaseModel): ...
else:
import pydantic.generics
class GenericModel(pydantic.generics.GenericModel, pydantic.BaseModel):
...
class GenericModel(pydantic.generics.GenericModel, pydantic.BaseModel): ...
# cached properties
@ -193,26 +190,21 @@ if TYPE_CHECKING:
func: Callable[[Any], _T]
attrname: str | None
def __init__(self, func: Callable[[Any], _T]) -> None:
...
def __init__(self, func: Callable[[Any], _T]) -> None: ...
@overload
def __get__(self, instance: None, owner: type[Any] | None = None) -> Self:
...
def __get__(self, instance: None, owner: type[Any] | None = None) -> Self: ...
@overload
def __get__(self, instance: object, owner: type[Any] | None = None) -> _T:
...
def __get__(self, instance: object, owner: type[Any] | None = None) -> _T: ...
def __get__(self, instance: object, owner: type[Any] | None = None) -> _T | Self:
raise NotImplementedError()
def __set_name__(self, owner: type[Any], name: str) -> None:
...
def __set_name__(self, owner: type[Any], name: str) -> None: ...
# __set__ is not defined at runtime, but @cached_property is designed to be settable
def __set__(self, instance: object, value: _T) -> None:
...
def __set__(self, instance: object, value: _T) -> None: ...
else:
try:
from functools import cached_property as cached_property

View file

@ -39,13 +39,11 @@ def assert_is_file_content(obj: object, *, key: str | None = None) -> None:
@overload
def to_httpx_files(files: None) -> None:
...
def to_httpx_files(files: None) -> None: ...
@overload
def to_httpx_files(files: RequestFiles) -> HttpxRequestFiles:
...
def to_httpx_files(files: RequestFiles) -> HttpxRequestFiles: ...
def to_httpx_files(files: RequestFiles | None) -> HttpxRequestFiles | None:
@ -83,13 +81,11 @@ def _read_file_content(file: FileContent) -> HttpxFileContent:
@overload
async def async_to_httpx_files(files: None) -> None:
...
async def async_to_httpx_files(files: None) -> None: ...
@overload
async def async_to_httpx_files(files: RequestFiles) -> HttpxRequestFiles:
...
async def async_to_httpx_files(files: RequestFiles) -> HttpxRequestFiles: ...
async def async_to_httpx_files(files: RequestFiles | None) -> HttpxRequestFiles | None:

View file

@ -262,12 +262,10 @@ class BaseAPIResponse(Generic[R]):
class APIResponse(BaseAPIResponse[R]):
@overload
def parse(self, *, to: type[_T]) -> _T:
...
def parse(self, *, to: type[_T]) -> _T: ...
@overload
def parse(self) -> R:
...
def parse(self) -> R: ...
def parse(self, *, to: type[_T] | None = None) -> R | _T:
"""Returns the rich python representation of this response's data.
@ -366,12 +364,10 @@ class APIResponse(BaseAPIResponse[R]):
class AsyncAPIResponse(BaseAPIResponse[R]):
@overload
async def parse(self, *, to: type[_T]) -> _T:
...
async def parse(self, *, to: type[_T]) -> _T: ...
@overload
async def parse(self) -> R:
...
async def parse(self) -> R: ...
async def parse(self, *, to: type[_T] | None = None) -> R | _T:
"""Returns the rich python representation of this response's data.

View file

@ -111,8 +111,7 @@ class NotGiven:
For example:
```py
def get(timeout: Union[int, NotGiven, None] = NotGiven()) -> Response:
...
def get(timeout: Union[int, NotGiven, None] = NotGiven()) -> Response: ...
get(timeout=1) # 1s timeout
@ -162,16 +161,14 @@ class ModelBuilderProtocol(Protocol):
*,
response: Response,
data: object,
) -> _T:
...
) -> _T: ...
Headers = Mapping[str, Union[str, Omit]]
class HeadersLikeProtocol(Protocol):
def get(self, __key: str) -> str | None:
...
def get(self, __key: str) -> str | None: ...
HeadersLike = Union[Headers, HeadersLikeProtocol]

View file

@ -59,5 +59,4 @@ class LazyProxy(Generic[T], ABC):
return cast(T, self)
@abstractmethod
def __load__(self) -> T:
...
def __load__(self) -> T: ...

View file

@ -211,20 +211,17 @@ def required_args(*variants: Sequence[str]) -> Callable[[CallableT], CallableT]:
Example usage:
```py
@overload
def foo(*, a: str) -> str:
...
def foo(*, a: str) -> str: ...
@overload
def foo(*, b: bool) -> str:
...
def foo(*, b: bool) -> str: ...
# This enforces the same constraints that a static type checker would
# i.e. that either a or b must be passed to the function
@required_args(["a"], ["b"])
def foo(*, a: str | None = None, b: bool | None = None) -> str:
...
def foo(*, a: str | None = None, b: bool | None = None) -> str: ...
```
"""
@ -286,18 +283,15 @@ _V = TypeVar("_V")
@overload
def strip_not_given(obj: None) -> None:
...
def strip_not_given(obj: None) -> None: ...
@overload
def strip_not_given(obj: Mapping[_K, _V | NotGiven]) -> dict[_K, _V]:
...
def strip_not_given(obj: Mapping[_K, _V | NotGiven]) -> dict[_K, _V]: ...
@overload
def strip_not_given(obj: object) -> object:
...
def strip_not_given(obj: object) -> object: ...
def strip_not_given(obj: object | None) -> object:

View file

@ -75,9 +75,9 @@ class FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameter
class FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemas(BaseModel):
last_updated: Optional[datetime] = None
parameter_schemas: Optional[
FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas
] = None
parameter_schemas: Optional[FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas] = (
None
)
"""An operation schema object containing a response."""

View file

@ -75,9 +75,9 @@ class FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameter
class FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemas(BaseModel):
last_updated: Optional[datetime] = None
parameter_schemas: Optional[
FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas
] = None
parameter_schemas: Optional[FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas] = (
None
)
"""An operation schema object containing a response."""

View file

@ -75,9 +75,9 @@ class FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameter
class FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemas(BaseModel):
last_updated: Optional[datetime] = None
parameter_schemas: Optional[
FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas
] = None
parameter_schemas: Optional[FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas] = (
None
)
"""An operation schema object containing a response."""

View file

@ -28,9 +28,9 @@ class IndicatorFeedGetResponse(BaseModel):
is_public: Optional[bool] = None
"""Whether the indicator feed is exposed to customers"""
latest_upload_status: Optional[
Literal["Mirroring", "Unifying", "Loading", "Provisioning", "Complete", "Error"]
] = None
latest_upload_status: Optional[Literal["Mirroring", "Unifying", "Loading", "Provisioning", "Complete", "Error"]] = (
None
)
"""Status of the latest snapshot uploaded"""
modified_on: Optional[datetime] = None

View file

@ -105,9 +105,9 @@ class DeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding(Base
class DeploymentConfigsPreviewAnalyticsEngineDatasets(BaseModel):
analytics_engine_binding: Optional[
DeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding
] = FieldInfo(alias="ANALYTICS_ENGINE_BINDING", default=None)
analytics_engine_binding: Optional[DeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding] = (
FieldInfo(alias="ANALYTICS_ENGINE_BINDING", default=None)
)
"""Analytics Engine binding."""
@ -305,9 +305,9 @@ class DeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding(B
class DeploymentConfigsProductionAnalyticsEngineDatasets(BaseModel):
analytics_engine_binding: Optional[
DeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding
] = FieldInfo(alias="ANALYTICS_ENGINE_BINDING", default=None)
analytics_engine_binding: Optional[DeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding] = (
FieldInfo(alias="ANALYTICS_ENGINE_BINDING", default=None)
)
"""Analytics Engine binding."""

View file

@ -14,8 +14,7 @@ class Serie0(BaseModel):
# Stub to indicate that arbitrary properties are accepted.
# To access properties that are not valid identifiers you can use `getattr`, e.g.
# `getattr(obj, '$type')`
def __getattr__(self, attr: str) -> List[str]:
...
def __getattr__(self, attr: str) -> List[str]: ...
class TimeseriesGroupIndustryResponse(BaseModel):

View file

@ -14,8 +14,7 @@ class Serie0(BaseModel):
# Stub to indicate that arbitrary properties are accepted.
# To access properties that are not valid identifiers you can use `getattr`, e.g.
# `getattr(obj, '$type')`
def __getattr__(self, attr: str) -> List[str]:
...
def __getattr__(self, attr: str) -> List[str]: ...
class TimeseriesGroupVectorResponse(BaseModel):

View file

@ -14,8 +14,7 @@ class Serie0(BaseModel):
# Stub to indicate that arbitrary properties are accepted.
# To access properties that are not valid identifiers you can use `getattr`, e.g.
# `getattr(obj, '$type')`
def __getattr__(self, attr: str) -> List[str]:
...
def __getattr__(self, attr: str) -> List[str]: ...
class TimeseriesGroupVerticalResponse(BaseModel):

View file

@ -14,8 +14,7 @@ class Serie0(BaseModel):
# Stub to indicate that arbitrary properties are accepted.
# To access properties that are not valid identifiers you can use `getattr`, e.g.
# `getattr(obj, '$type')`
def __getattr__(self, attr: str) -> List[str]:
...
def __getattr__(self, attr: str) -> List[str]: ...
class TimeseriesGroupIndustryResponse(BaseModel):

View file

@ -14,8 +14,7 @@ class Serie0(BaseModel):
# Stub to indicate that arbitrary properties are accepted.
# To access properties that are not valid identifiers you can use `getattr`, e.g.
# `getattr(obj, '$type')`
def __getattr__(self, attr: str) -> List[str]:
...
def __getattr__(self, attr: str) -> List[str]: ...
class TimeseriesGroupVerticalResponse(BaseModel):

View file

@ -14,8 +14,7 @@ class Serie0(BaseModel):
# Stub to indicate that arbitrary properties are accepted.
# To access properties that are not valid identifiers you can use `getattr`, e.g.
# `getattr(obj, '$type')`
def __getattr__(self, attr: str) -> List[str]:
...
def __getattr__(self, attr: str) -> List[str]: ...
class TimeseriesGroupBrowserFamilyResponse(BaseModel):

View file

@ -14,8 +14,7 @@ class Serie0(BaseModel):
# Stub to indicate that arbitrary properties are accepted.
# To access properties that are not valid identifiers you can use `getattr`, e.g.
# `getattr(obj, '$type')`
def __getattr__(self, attr: str) -> List[str]:
...
def __getattr__(self, attr: str) -> List[str]: ...
class TimeseriesGroupBrowserResponse(BaseModel):

View file

@ -14,8 +14,7 @@ class Serie0(BaseModel):
# Stub to indicate that arbitrary properties are accepted.
# To access properties that are not valid identifiers you can use `getattr`, e.g.
# `getattr(obj, '$type')`
def __getattr__(self, attr: str) -> List[str]:
...
def __getattr__(self, attr: str) -> List[str]: ...
class TimeseriesGroupOSResponse(BaseModel):

View file

@ -29,8 +29,7 @@ class Serie0(BaseModel):
# Stub to indicate that arbitrary properties are accepted.
# To access properties that are not valid identifiers you can use `getattr`, e.g.
# `getattr(obj, '$type')`
def __getattr__(self, attr: str) -> List[Union[str, float]]:
...
def __getattr__(self, attr: str) -> List[Union[str, float]]: ...
class RankingTimeseriesGroupsResponse(BaseModel):

View file

@ -18,9 +18,9 @@ class ActionParameters(BaseModel):
This option is incompatible with the ruleset and rulesets options.
"""
products: Optional[
List[Literal["bic", "hot", "rateLimit", "securityLevel", "uaBlock", "waf", "zoneLockdown"]]
] = None
products: Optional[List[Literal["bic", "hot", "rateLimit", "securityLevel", "uaBlock", "waf", "zoneLockdown"]]] = (
None
)
"""A list of legacy security products to skip the execution of."""
rules: Optional[Dict[str, List[str]]] = None

View file

@ -41,8 +41,7 @@ def test_nested_list() -> None:
assert_different_identities(obj1[1], obj2[1])
class MyObject:
...
class MyObject: ...
def test_ignores_other_types() -> None:

View file

@ -19,16 +19,13 @@ from cloudflare._streaming import Stream
from cloudflare._base_client import FinalRequestOptions
class ConcreteBaseAPIResponse(APIResponse[bytes]):
...
class ConcreteBaseAPIResponse(APIResponse[bytes]): ...
class ConcreteAPIResponse(APIResponse[List[str]]):
...
class ConcreteAPIResponse(APIResponse[List[str]]): ...
class ConcreteAsyncAPIResponse(APIResponse[httpx.Response]):
...
class ConcreteAsyncAPIResponse(APIResponse[httpx.Response]): ...
def test_extract_response_type_direct_classes() -> None:
@ -56,8 +53,7 @@ def test_extract_response_type_binary_response() -> None:
assert extract_response_type(AsyncBinaryAPIResponse) == bytes
class PydanticModel(pydantic.BaseModel):
...
class PydanticModel(pydantic.BaseModel): ...
def test_response_parse_mismatched_basemodel(client: Cloudflare) -> None:

View file

@ -9,24 +9,19 @@ _T2 = TypeVar("_T2")
_T3 = TypeVar("_T3")
class BaseGeneric(Generic[_T]):
...
class BaseGeneric(Generic[_T]): ...
class SubclassGeneric(BaseGeneric[_T]):
...
class SubclassGeneric(BaseGeneric[_T]): ...
class BaseGenericMultipleTypeArgs(Generic[_T, _T2, _T3]):
...
class BaseGenericMultipleTypeArgs(Generic[_T, _T2, _T3]): ...
class SubclassGenericMultipleTypeArgs(BaseGenericMultipleTypeArgs[_T, _T2, _T3]):
...
class SubclassGenericMultipleTypeArgs(BaseGenericMultipleTypeArgs[_T, _T2, _T3]): ...
class SubclassDifferentOrderGenericMultipleTypeArgs(BaseGenericMultipleTypeArgs[_T2, _T, _T3]):
...
class SubclassDifferentOrderGenericMultipleTypeArgs(BaseGenericMultipleTypeArgs[_T2, _T, _T3]): ...
def test_extract_type_var() -> None: