mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-11 00:52:41 +00:00
[python-nextgen] Various fixes reported by pylint (#15309)
* various pylint fixes
* rearrange test
* Revert "rearrange test"
This reverts commit 24d777a8a8.
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
from inspect import getfullargspec
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
@@ -32,6 +31,7 @@ class Bird(BaseModel):
|
||||
__properties = ["size", "color"]
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
@@ -62,7 +62,7 @@ class Bird(BaseModel):
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if type(obj) is not dict:
|
||||
if not isinstance(obj, dict):
|
||||
return Bird.parse_obj(obj)
|
||||
|
||||
_obj = Bird.parse_obj({
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
from inspect import getfullargspec
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
@@ -32,6 +31,7 @@ class Category(BaseModel):
|
||||
__properties = ["id", "name"]
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
@@ -62,7 +62,7 @@ class Category(BaseModel):
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if type(obj) is not dict:
|
||||
if not isinstance(obj, dict):
|
||||
return Category.parse_obj(obj)
|
||||
|
||||
_obj = Category.parse_obj({
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
from inspect import getfullargspec
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
@@ -34,6 +33,7 @@ class DataQuery(Query):
|
||||
__properties = ["suffix", "text", "date", "id", "outcomes"]
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
@@ -64,7 +64,7 @@ class DataQuery(Query):
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if type(obj) is not dict:
|
||||
if not isinstance(obj, dict):
|
||||
return DataQuery.parse_obj(obj)
|
||||
|
||||
_obj = DataQuery.parse_obj({
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
from inspect import getfullargspec
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
@@ -33,6 +32,7 @@ class DataQueryAllOf(BaseModel):
|
||||
__properties = ["suffix", "text", "date"]
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
@@ -63,7 +63,7 @@ class DataQueryAllOf(BaseModel):
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if type(obj) is not dict:
|
||||
if not isinstance(obj, dict):
|
||||
return DataQueryAllOf.parse_obj(obj)
|
||||
|
||||
_obj = DataQueryAllOf.parse_obj({
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
from inspect import getfullargspec
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
@@ -39,16 +38,18 @@ class DefaultValue(BaseModel):
|
||||
__properties = ["array_string_enum_ref_default", "array_string_enum_default", "array_string_default", "array_integer_default", "array_string", "array_string_nullable", "array_string_extension_nullable", "string_nullable"]
|
||||
|
||||
@validator('array_string_enum_default')
|
||||
def array_string_enum_default_validate_enum(cls, v):
|
||||
if v is None:
|
||||
return v
|
||||
def array_string_enum_default_validate_enum(cls, value):
|
||||
"""Validates the enum"""
|
||||
if value is None:
|
||||
return value
|
||||
|
||||
for i in v:
|
||||
for i in value:
|
||||
if i not in ('success', 'failure', 'unclassified'):
|
||||
raise ValueError("each list item must be one of ('success', 'failure', 'unclassified')")
|
||||
return v
|
||||
return value
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
@@ -94,7 +95,7 @@ class DefaultValue(BaseModel):
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if type(obj) is not dict:
|
||||
if not isinstance(obj, dict):
|
||||
return DefaultValue.parse_obj(obj)
|
||||
|
||||
_obj = DefaultValue.parse_obj({
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
from inspect import getfullargspec
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
@@ -33,6 +32,7 @@ class NumberPropertiesOnly(BaseModel):
|
||||
__properties = ["number", "float", "double"]
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
@@ -63,7 +63,7 @@ class NumberPropertiesOnly(BaseModel):
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if type(obj) is not dict:
|
||||
if not isinstance(obj, dict):
|
||||
return NumberPropertiesOnly.parse_obj(obj)
|
||||
|
||||
_obj = NumberPropertiesOnly.parse_obj({
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
from inspect import getfullargspec
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
@@ -38,15 +37,17 @@ class Pet(BaseModel):
|
||||
__properties = ["id", "name", "category", "photoUrls", "tags", "status"]
|
||||
|
||||
@validator('status')
|
||||
def status_validate_enum(cls, v):
|
||||
if v is None:
|
||||
return v
|
||||
def status_validate_enum(cls, value):
|
||||
"""Validates the enum"""
|
||||
if value is None:
|
||||
return value
|
||||
|
||||
if v not in ('available', 'pending', 'sold'):
|
||||
if value not in ('available', 'pending', 'sold'):
|
||||
raise ValueError("must be one of enum values ('available', 'pending', 'sold')")
|
||||
return v
|
||||
return value
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
@@ -87,7 +88,7 @@ class Pet(BaseModel):
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if type(obj) is not dict:
|
||||
if not isinstance(obj, dict):
|
||||
return Pet.parse_obj(obj)
|
||||
|
||||
_obj = Pet.parse_obj({
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
from inspect import getfullargspec
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
@@ -32,16 +31,18 @@ class Query(BaseModel):
|
||||
__properties = ["id", "outcomes"]
|
||||
|
||||
@validator('outcomes')
|
||||
def outcomes_validate_enum(cls, v):
|
||||
if v is None:
|
||||
return v
|
||||
def outcomes_validate_enum(cls, value):
|
||||
"""Validates the enum"""
|
||||
if value is None:
|
||||
return value
|
||||
|
||||
for i in v:
|
||||
for i in value:
|
||||
if i not in ('SUCCESS', 'FAILURE', 'SKIPPED'):
|
||||
raise ValueError("each list item must be one of ('SUCCESS', 'FAILURE', 'SKIPPED')")
|
||||
return v
|
||||
return value
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
from inspect import getfullargspec
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
@@ -32,6 +31,7 @@ class Tag(BaseModel):
|
||||
__properties = ["id", "name"]
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
@@ -62,7 +62,7 @@ class Tag(BaseModel):
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if type(obj) is not dict:
|
||||
if not isinstance(obj, dict):
|
||||
return Tag.parse_obj(obj)
|
||||
|
||||
_obj = Tag.parse_obj({
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
from inspect import getfullargspec
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
@@ -34,6 +33,7 @@ class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter(BaseMod
|
||||
__properties = ["size", "color", "id", "name"]
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
@@ -64,7 +64,7 @@ class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter(BaseMod
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if type(obj) is not dict:
|
||||
if not isinstance(obj, dict):
|
||||
return TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.parse_obj(obj)
|
||||
|
||||
_obj = TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.parse_obj({
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
from inspect import getfullargspec
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
@@ -31,6 +30,7 @@ class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(BaseModel):
|
||||
__properties = ["values"]
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
@@ -61,7 +61,7 @@ class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(BaseModel):
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if type(obj) is not dict:
|
||||
if not isinstance(obj, dict):
|
||||
return TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.parse_obj(obj)
|
||||
|
||||
_obj = TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.parse_obj({
|
||||
|
||||
@@ -13,7 +13,7 @@ python = "^3.7"
|
||||
|
||||
urllib3 = ">= 1.25.3"
|
||||
python-dateutil = ">=2.8.2"
|
||||
pydantic = "^1.10.5"
|
||||
pydantic = "^1.10.5, <2"
|
||||
aenum = ">=3.1.11"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
@@ -25,3 +25,5 @@ flake8 = ">=4.0.0"
|
||||
requires = ["setuptools"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[tool.pylint.'MESSAGES CONTROL']
|
||||
extension-pkg-whitelist = "pydantic"
|
||||
|
||||
Reference in New Issue
Block a user