forked from loafle/openapi-generator-original
python: adjust basic typing information (#17511)
* python: adjust basic typing information This is an initial pass to fix and adjust the typing information for the generated client. This is enough to have mypy runnning without complains on all the (modern) generated clients (Pydantic v1 code is not checked for instance) mypy is also now run directly in the CI, so further changes will also be checked and thus, will need to be compliant with good typing information. Note that this doesn't *fully* type all the code: mypy is not run in "strict" mode and there are still many functions/methods/attributes which are still not fully typed, but it's a first good step in that direction. * ApiResponse's raw_data can't be None * Fix indentation * Revert test changes * run mypy on tests/ directory * don't forcefully convert the client response headers to dict * override petstore ApiResponse model * adjust type of 'any/one_of_schemas' fields
This commit is contained in:
@@ -15,11 +15,7 @@
|
||||
import warnings
|
||||
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
||||
|
||||
try:
|
||||
from typing import Annotated
|
||||
except ImportError:
|
||||
from typing_extensions import Annotated
|
||||
from typing_extensions import Annotated
|
||||
|
||||
|
||||
from openapi_client.api_client import ApiClient
|
||||
|
||||
@@ -15,11 +15,7 @@
|
||||
import warnings
|
||||
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
||||
|
||||
try:
|
||||
from typing import Annotated
|
||||
except ImportError:
|
||||
from typing_extensions import Annotated
|
||||
from typing_extensions import Annotated
|
||||
|
||||
from pydantic import Field, StrictBytes, StrictStr
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
|
||||
@@ -15,11 +15,7 @@
|
||||
import warnings
|
||||
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
||||
|
||||
try:
|
||||
from typing import Annotated
|
||||
except ImportError:
|
||||
from typing_extensions import Annotated
|
||||
from typing_extensions import Annotated
|
||||
|
||||
from pydantic import StrictBool, StrictInt, StrictStr
|
||||
from typing import Optional
|
||||
|
||||
@@ -15,11 +15,7 @@
|
||||
import warnings
|
||||
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
||||
|
||||
try:
|
||||
from typing import Annotated
|
||||
except ImportError:
|
||||
from typing_extensions import Annotated
|
||||
from typing_extensions import Annotated
|
||||
|
||||
from pydantic import StrictBool, StrictInt, StrictStr, field_validator
|
||||
from typing import Optional
|
||||
|
||||
@@ -15,11 +15,7 @@
|
||||
import warnings
|
||||
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
||||
|
||||
try:
|
||||
from typing import Annotated
|
||||
except ImportError:
|
||||
from typing_extensions import Annotated
|
||||
from typing_extensions import Annotated
|
||||
|
||||
from pydantic import StrictInt, StrictStr, field_validator
|
||||
from openapi_client.models.string_enum_ref import StringEnumRef
|
||||
|
||||
@@ -15,11 +15,7 @@
|
||||
import warnings
|
||||
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
||||
|
||||
try:
|
||||
from typing import Annotated
|
||||
except ImportError:
|
||||
from typing_extensions import Annotated
|
||||
from typing_extensions import Annotated
|
||||
|
||||
from datetime import date, datetime
|
||||
from pydantic import StrictBool, StrictInt, StrictStr, field_validator
|
||||
|
||||
@@ -273,15 +273,13 @@ class ApiClient:
|
||||
)
|
||||
|
||||
except ApiException as e:
|
||||
if e.body:
|
||||
e.body = e.body.decode('utf-8')
|
||||
raise e
|
||||
|
||||
return response_data
|
||||
|
||||
def response_deserialize(
|
||||
self,
|
||||
response_data: rest.RESTResponse = None,
|
||||
response_data: rest.RESTResponse,
|
||||
response_types_map=None
|
||||
) -> ApiResponse:
|
||||
"""Deserializes response into an object.
|
||||
@@ -290,6 +288,8 @@ class ApiClient:
|
||||
:return: ApiResponse
|
||||
"""
|
||||
|
||||
msg = "RESTResponse.read() must be called before passing it to response_deserialize()"
|
||||
assert response_data.data is not None, msg
|
||||
|
||||
response_type = response_types_map.get(str(response_data.status), None)
|
||||
if not response_type and isinstance(response_data.status, int) and 100 <= response_data.status <= 599:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"""API response object."""
|
||||
|
||||
from __future__ import annotations
|
||||
from typing import Dict, Optional, Generic, TypeVar
|
||||
from pydantic import Field, StrictInt, StrictStr, StrictBytes, BaseModel
|
||||
from typing import Optional, Generic, Mapping, TypeVar
|
||||
from pydantic import Field, StrictInt, StrictBytes, BaseModel
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
@@ -12,7 +12,7 @@ class ApiResponse(BaseModel, Generic[T]):
|
||||
"""
|
||||
|
||||
status_code: StrictInt = Field(description="HTTP status code")
|
||||
headers: Optional[Dict[StrictStr, StrictStr]] = Field(None, description="HTTP headers")
|
||||
headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers")
|
||||
data: T = Field(description="Deserialized data given the data type")
|
||||
raw_data: StrictBytes = Field(description="Raw data (HTTP response body)")
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
""" # noqa: E501
|
||||
|
||||
from typing import Any, Optional
|
||||
|
||||
from typing_extensions import Self
|
||||
|
||||
class OpenApiException(Exception):
|
||||
|
||||
@@ -20,10 +20,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class Bird(BaseModel):
|
||||
"""
|
||||
@@ -50,7 +48,7 @@ class Bird(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Bird from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -64,16 +62,18 @@ class Bird(BaseModel):
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of Bird from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -20,10 +20,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class Category(BaseModel):
|
||||
"""
|
||||
@@ -50,7 +48,7 @@ class Category(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Category from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -64,16 +62,18 @@ class Category(BaseModel):
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of Category from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -22,10 +22,8 @@ from datetime import datetime
|
||||
from pydantic import Field, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from openapi_client.models.query import Query
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class DataQuery(Query):
|
||||
"""
|
||||
@@ -53,7 +51,7 @@ class DataQuery(Query):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of DataQuery from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -67,16 +65,18 @@ class DataQuery(Query):
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of DataQuery from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -21,10 +21,8 @@ import json
|
||||
from pydantic import BaseModel, StrictInt, StrictStr, field_validator
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from openapi_client.models.string_enum_ref import StringEnumRef
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class DefaultValue(BaseModel):
|
||||
"""
|
||||
@@ -68,7 +66,7 @@ class DefaultValue(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of DefaultValue from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -82,10 +80,12 @@ class DefaultValue(BaseModel):
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# set to None if array_string_nullable (nullable) is None
|
||||
@@ -106,7 +106,7 @@ class DefaultValue(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of DefaultValue from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -21,10 +21,8 @@ import json
|
||||
from pydantic import BaseModel, Field, StrictFloat, StrictInt
|
||||
from typing import Any, ClassVar, Dict, List, Optional, Union
|
||||
from typing_extensions import Annotated
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class NumberPropertiesOnly(BaseModel):
|
||||
"""
|
||||
@@ -52,7 +50,7 @@ class NumberPropertiesOnly(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of NumberPropertiesOnly from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -66,16 +64,18 @@ class NumberPropertiesOnly(BaseModel):
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of NumberPropertiesOnly from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -22,10 +22,8 @@ from pydantic import BaseModel, Field, StrictInt, StrictStr, field_validator
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from openapi_client.models.category import Category
|
||||
from openapi_client.models.tag import Tag
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class Pet(BaseModel):
|
||||
"""
|
||||
@@ -66,7 +64,7 @@ class Pet(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Pet from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -80,10 +78,12 @@ class Pet(BaseModel):
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of category
|
||||
@@ -99,7 +99,7 @@ class Pet(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of Pet from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
@@ -115,9 +115,9 @@ class Pet(BaseModel):
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"name": obj.get("name"),
|
||||
"category": Category.from_dict(obj.get("category")) if obj.get("category") is not None else None,
|
||||
"category": Category.from_dict(obj["category"]) if obj.get("category") is not None else None,
|
||||
"photoUrls": obj.get("photoUrls"),
|
||||
"tags": [Tag.from_dict(_item) for _item in obj.get("tags")] if obj.get("tags") is not None else None,
|
||||
"tags": [Tag.from_dict(_item) for _item in obj["tags"]] if obj.get("tags") is not None else None,
|
||||
"status": obj.get("status")
|
||||
})
|
||||
return _obj
|
||||
|
||||
@@ -20,10 +20,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, Field, StrictInt, StrictStr, field_validator
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class Query(BaseModel):
|
||||
"""
|
||||
@@ -61,7 +59,7 @@ class Query(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Query from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -75,16 +73,18 @@ class Query(BaseModel):
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Dict) -> Optional[Self]:
|
||||
"""Create an instance of Query from a dict"""
|
||||
|
||||
|
||||
|
||||
@@ -20,10 +20,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class Tag(BaseModel):
|
||||
"""
|
||||
@@ -50,7 +48,7 @@ class Tag(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Tag from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -64,16 +62,18 @@ class Tag(BaseModel):
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of Tag from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -20,10 +20,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter(BaseModel):
|
||||
"""
|
||||
@@ -52,7 +50,7 @@ class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter(BaseMod
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -66,16 +64,18 @@ class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter(BaseMod
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -20,10 +20,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(BaseModel):
|
||||
"""
|
||||
@@ -49,7 +47,7 @@ class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -63,16 +61,18 @@ class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(BaseModel):
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -72,56 +72,45 @@ class RESTClientObject:
|
||||
else:
|
||||
cert_reqs = ssl.CERT_NONE
|
||||
|
||||
addition_pool_args = {}
|
||||
pool_args = {
|
||||
"cert_reqs": cert_reqs,
|
||||
"ca_certs": configuration.ssl_ca_cert,
|
||||
"cert_file": configuration.cert_file,
|
||||
"key_file": configuration.key_file,
|
||||
}
|
||||
if configuration.assert_hostname is not None:
|
||||
addition_pool_args['assert_hostname'] = (
|
||||
pool_args['assert_hostname'] = (
|
||||
configuration.assert_hostname
|
||||
)
|
||||
|
||||
if configuration.retries is not None:
|
||||
addition_pool_args['retries'] = configuration.retries
|
||||
pool_args['retries'] = configuration.retries
|
||||
|
||||
if configuration.tls_server_name:
|
||||
addition_pool_args['server_hostname'] = configuration.tls_server_name
|
||||
pool_args['server_hostname'] = configuration.tls_server_name
|
||||
|
||||
|
||||
if configuration.socket_options is not None:
|
||||
addition_pool_args['socket_options'] = configuration.socket_options
|
||||
pool_args['socket_options'] = configuration.socket_options
|
||||
|
||||
if configuration.connection_pool_maxsize is not None:
|
||||
addition_pool_args['maxsize'] = configuration.connection_pool_maxsize
|
||||
pool_args['maxsize'] = configuration.connection_pool_maxsize
|
||||
|
||||
# https pool manager
|
||||
self.pool_manager: urllib3.PoolManager
|
||||
|
||||
if configuration.proxy:
|
||||
if is_socks_proxy_url(configuration.proxy):
|
||||
from urllib3.contrib.socks import SOCKSProxyManager
|
||||
self.pool_manager = SOCKSProxyManager(
|
||||
cert_reqs=cert_reqs,
|
||||
ca_certs=configuration.ssl_ca_cert,
|
||||
cert_file=configuration.cert_file,
|
||||
key_file=configuration.key_file,
|
||||
proxy_url=configuration.proxy,
|
||||
headers=configuration.proxy_headers,
|
||||
**addition_pool_args
|
||||
)
|
||||
pool_args["proxy_url"] = configuration.proxy
|
||||
pool_args["headers"] = configuration.proxy_headers
|
||||
self.pool_manager = SOCKSProxyManager(**pool_args)
|
||||
else:
|
||||
self.pool_manager = urllib3.ProxyManager(
|
||||
cert_reqs=cert_reqs,
|
||||
ca_certs=configuration.ssl_ca_cert,
|
||||
cert_file=configuration.cert_file,
|
||||
key_file=configuration.key_file,
|
||||
proxy_url=configuration.proxy,
|
||||
proxy_headers=configuration.proxy_headers,
|
||||
**addition_pool_args
|
||||
)
|
||||
pool_args["proxy_url"] = configuration.proxy
|
||||
pool_args["proxy_headers"] = configuration.proxy_headers
|
||||
self.pool_manager = urllib3.ProxyManager(**pool_args)
|
||||
else:
|
||||
self.pool_manager = urllib3.PoolManager(
|
||||
cert_reqs=cert_reqs,
|
||||
ca_certs=configuration.ssl_ca_cert,
|
||||
cert_file=configuration.cert_file,
|
||||
key_file=configuration.key_file,
|
||||
**addition_pool_args
|
||||
)
|
||||
self.pool_manager = urllib3.PoolManager(**pool_args)
|
||||
|
||||
def request(
|
||||
self,
|
||||
|
||||
@@ -21,6 +21,9 @@ typing-extensions = ">=4.7.1"
|
||||
pytest = ">=7.2.1"
|
||||
tox = ">=3.9.0"
|
||||
flake8 = ">=4.0.0"
|
||||
types-python-dateutil = ">=2.8.19.14"
|
||||
mypy = "1.4.1"
|
||||
|
||||
|
||||
[build-system]
|
||||
requires = ["setuptools"]
|
||||
@@ -28,3 +31,10 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[tool.pylint.'MESSAGES CONTROL']
|
||||
extension-pkg-whitelist = "pydantic"
|
||||
|
||||
[tool.mypy]
|
||||
files = [
|
||||
"openapi_client",
|
||||
#"test", # auto-generated tests
|
||||
"tests", # hand-written tests
|
||||
]
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
pytest~=7.1.3
|
||||
pytest-cov>=2.8.1
|
||||
pytest-randomly>=3.12.0
|
||||
mypy>=1.4.1
|
||||
types-python-dateutil>=2.8.19
|
||||
|
||||
Reference in New Issue
Block a user