1.4.0
This commit is contained in:
@@ -18,12 +18,13 @@ from typing import (
|
||||
)
|
||||
|
||||
import requests
|
||||
from pydantic import (
|
||||
from pydantic import ( # noqa: F401
|
||||
AliasGenerator,
|
||||
BaseModel as PydanticBaseModel,
|
||||
ConfigDict,
|
||||
PrivateAttr,
|
||||
create_model,
|
||||
computed_field,
|
||||
)
|
||||
import yaml
|
||||
|
||||
@@ -248,11 +249,17 @@ def get_alias(
|
||||
f' not found in name mapping dictionary.'
|
||||
)
|
||||
|
||||
if field_name in model_cls.model_computed_fields:
|
||||
return field_name
|
||||
|
||||
for base_cls in model_cls.__bases__:
|
||||
if not issubclass(base_cls, BaseModel):
|
||||
continue
|
||||
|
||||
if field_name not in base_cls.model_fields.keys():
|
||||
if (
|
||||
field_name not in base_cls.model_fields.keys()
|
||||
and field_name not in base_cls.model_computed_fields
|
||||
):
|
||||
continue
|
||||
|
||||
return get_alias(
|
||||
@@ -391,23 +398,22 @@ class BaseAPI(ABC):
|
||||
def __getattribute__(self, name: str) -> Any:
|
||||
if name.startswith('_'):
|
||||
return super().__getattribute__(name)
|
||||
else:
|
||||
if name in self.__annotations__:
|
||||
annotation = self.__annotations__[name]
|
||||
if issubclass(annotation, BaseAPI):
|
||||
api_cls = annotation
|
||||
return api_cls(
|
||||
config=self._config,
|
||||
parent_api_group_names=(
|
||||
self._parent_api_group_names + [name]
|
||||
)
|
||||
if name in self.__annotations__:
|
||||
annotation = self.__annotations__[name]
|
||||
if issubclass(annotation, BaseAPI):
|
||||
api_cls = annotation
|
||||
return api_cls(
|
||||
config=self._config,
|
||||
parent_api_group_names=(
|
||||
self._parent_api_group_names + [name]
|
||||
)
|
||||
else:
|
||||
attr_value = super().__getattribute__(name)
|
||||
if not inspect.ismethod(attr_value):
|
||||
raise ValueError
|
||||
)
|
||||
attr_value = super().__getattribute__(name)
|
||||
|
||||
return self._make_api_function(attr_value)
|
||||
if inspect.ismethod(attr_value):
|
||||
return self._make_api_function(attr_value)
|
||||
|
||||
return attr_value
|
||||
|
||||
def _make_api_function(
|
||||
self,
|
||||
@@ -523,6 +529,7 @@ class BaseAPI(ABC):
|
||||
).prepare()
|
||||
|
||||
attempts = config.http503_attempts
|
||||
status_code = None
|
||||
try:
|
||||
with requests.Session() as session:
|
||||
while True:
|
||||
@@ -531,7 +538,8 @@ class BaseAPI(ABC):
|
||||
verify=config.verify_ssl,
|
||||
)
|
||||
|
||||
if http_response.status_code == 503:
|
||||
status_code = http_response.status_code
|
||||
if status_code == 503:
|
||||
if attempts < 1:
|
||||
break
|
||||
else:
|
||||
@@ -547,6 +555,7 @@ class BaseAPI(ABC):
|
||||
orig_exception=e,
|
||||
func_name=func_name,
|
||||
func_kwargs=kwargs,
|
||||
status_code=status_code,
|
||||
)
|
||||
else:
|
||||
raise e
|
||||
|
||||
Reference in New Issue
Block a user