python: generate Pydantic v2 + typing complete code (#16624)

* python: improve type generation with more specific typing

* Annotate function parameters

* Remove unused imports

* remove unused files

* remove temporary hack

* remove lock file

* fix Annotated import

* support Python 3.7

* Regenerate code with typing-extensions

* Fix setup.py

* More Pydantic v2 compatibility

* depend on pydantic v2

* fix client_echo tests

* fix JSON serialization

* Fix references

* Skip circular dependency tests for now

* Temporarily hide the "float" property

The "float" property aliases the "float" type and completely breaks the
model: all the properties that were "float" now become the type of the
"float" property instead.

* Fix errors

* Import Literal from typing_extensions

* Fix GitHub Action workflows

* Fix Python 3.7 failure

* Fix quotes

* Apply suggestions from code review

* Fix tests

* split model imports from other modules imports

* fix workflow

* Comment the array unique items convertion, remove set translation

* Replace alias usage
This commit is contained in:
Jonathan Ballet
2023-09-28 13:13:14 +02:00
committed by GitHub
parent af352df10f
commit 04fa53b692
219 changed files with 3305 additions and 1566 deletions

View File

@@ -36,12 +36,12 @@ class TestAnimal(unittest.TestCase):
# model = petstore_api.models.animal.Animal() # noqa: E501
if include_optional :
return Animal(
class_name = '',
className = '',
color = 'red'
)
else :
return Animal(
class_name = '',
className = '',
)
def testAnimal(self):

View File

@@ -46,7 +46,7 @@ class TestFormatTest(unittest.TestCase):
string = 'a',
byte = bytes("someting", 'utf-8'),
binary = bytes(b'blah'),
date = datetime.datetime.strptime('1975-12-30', '%Y-%m-%d').date(),
var_date = datetime.datetime.strptime('1975-12-30', '%Y-%m-%d').date(),
date_time = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'),
uuid = '72f98069-206d-4f12-9f12-3d1e525a8e84',
password = '0123456789',

View File

@@ -40,7 +40,7 @@ class TestMixedPropertiesAndAdditionalPropertiesClass(unittest.TestCase):
date_time = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'),
map = {
'key' : petstore_api.models.animal.Animal(
class_name = '',
className = '',
color = 'red', )
}
)

View File

@@ -41,7 +41,7 @@ class TestPet(unittest.TestCase):
id = 56,
name = 'default-name', ),
name = 'doggie',
photo_urls = [
photoUrls = [
''
],
tags = [
@@ -54,7 +54,7 @@ class TestPet(unittest.TestCase):
else :
return Pet(
name = 'doggie',
photo_urls = [
photoUrls = [
''
],
)