Skip to content

Commit e5a4e5a

Browse files
author
luolingchun
committed
Drop support for Python 3.8
1 parent 79ed3fe commit e5a4e5a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+204
-220
lines changed

docs/Usage/Model_Config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Sometimes you may not want to use aliases (such as in the responses model). In t
130130
```python
131131
class MessageResponse(BaseModel):
132132
message: str = Field(..., description="The message")
133-
metadata: Dict[str, str] = Field(alias="metadata_")
133+
metadata: dict[str, str] = Field(alias="metadata_")
134134

135135
model_config = dict(
136136
by_alias=False

examples/openapi_extra.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# -*- coding: utf-8 -*-
22
# @Author : llc
33
# @Time : 2023/6/1 15:04
4-
from typing import List
5-
64
from pydantic import BaseModel
75

86
from flask_openapi3 import OpenAPI, FileStorage
@@ -12,7 +10,7 @@
1210

1311
class UploadFilesForm(BaseModel):
1412
file: FileStorage
15-
str_list: List[str]
13+
str_list: list[str]
1614

1715
model_config = dict(
1816
openapi_extra={

examples/pydantic_custom_root_types.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
# @Author : llc
33
# @Time : 2022/2/27 15:26
4-
from typing import List, Dict, Any
4+
from typing import Any
55

66
from pydantic import BaseModel, RootModel
77

@@ -16,15 +16,15 @@ class Sellout(BaseModel):
1616

1717

1818
class SelloutList(RootModel):
19-
root: List[Sellout]
19+
root: list[Sellout]
2020

2121

2222
class SelloutDict(RootModel):
23-
root: Dict[str, Sellout]
23+
root: dict[str, Sellout]
2424

2525

2626
class SelloutDict2(RootModel):
27-
root: Dict[Any, Any]
27+
root: dict[Any, Any]
2828

2929

3030
class SelloutDict3(BaseModel):

examples/rest_demo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# @Author : llc
33
# @Time : 2021/4/28 11:24
44
from http import HTTPStatus
5-
from typing import Optional, List
5+
from typing import Optional
66

77
from pydantic import BaseModel, Field
88

@@ -66,7 +66,7 @@ class BookPath(BaseModel):
6666

6767
class BookQuery(BaseModel):
6868
age: Optional[int] = Field(None, description='Age')
69-
s_list: List[str] = Field(None, alias='s_list[]', description='some array')
69+
s_list: list[str] = Field(None, alias='s_list[]', description='some array')
7070

7171

7272
class BookBody(BaseModel):

examples/upload_file_demo.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# -*- coding: utf-8 -*-
22
# @Author : llc
33
# @Time : 2021/5/11 14:03
4-
5-
from typing import List
6-
74
from pydantic import BaseModel, Field
85

96
from flask_openapi3 import OpenAPI, FileStorage
@@ -17,9 +14,9 @@ class UploadFileForm(BaseModel):
1714

1815

1916
class UploadFilesForm(BaseModel):
20-
files: List[FileStorage]
21-
str_list: List[str]
22-
int_list: List[int]
17+
files: list[FileStorage]
18+
str_list: list[str]
19+
int_list: list[int]
2320

2421

2522
@app.post('/upload/file')

flask_openapi3/blueprint.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
# @Author : llc
33
# @Time : 2022/4/1 16:54
4-
from typing import Optional, List, Dict, Any, Callable
4+
from typing import Optional, Any, Callable
55

66
from flask import Blueprint
77

@@ -28,8 +28,8 @@ def __init__(
2828
name: str,
2929
import_name: str,
3030
*,
31-
abp_tags: Optional[List[Tag]] = None,
32-
abp_security: Optional[List[Dict[str, List[str]]]] = None,
31+
abp_tags: Optional[list[Tag]] = None,
32+
abp_security: Optional[list[dict[str, list[str]]]] = None,
3333
abp_responses: Optional[ResponseDict] = None,
3434
doc_ui: bool = True,
3535
operation_id_callback: Callable = get_operation_id_for_path,
@@ -54,10 +54,10 @@ def __init__(
5454
super(APIBlueprint, self).__init__(name, import_name, **kwargs)
5555

5656
# Initialize instance variables
57-
self.paths: Dict = dict()
58-
self.components_schemas: Dict = dict()
59-
self.tags: List[Tag] = []
60-
self.tag_names: List[str] = []
57+
self.paths: dict = dict()
58+
self.components_schemas: dict = dict()
59+
self.tags: list[Tag] = []
60+
self.tag_names: list[str] = []
6161

6262
# Set values from arguments or default values
6363
self.abp_tags = abp_tags or []
@@ -111,16 +111,16 @@ def _collect_openapi_info(
111111
rule: str,
112112
func: Callable,
113113
*,
114-
tags: Optional[List[Tag]] = None,
114+
tags: Optional[list[Tag]] = None,
115115
summary: Optional[str] = None,
116116
description: Optional[str] = None,
117117
external_docs: Optional[ExternalDocumentation] = None,
118118
operation_id: Optional[str] = None,
119119
responses: Optional[ResponseDict] = None,
120120
deprecated: Optional[bool] = None,
121-
security: Optional[List[Dict[str, List[Any]]]] = None,
122-
servers: Optional[List[Server]] = None,
123-
openapi_extensions: Optional[Dict[str, Any]] = None,
121+
security: Optional[list[dict[str, list[Any]]]] = None,
122+
servers: Optional[list[Server]] = None,
123+
openapi_extensions: Optional[dict[str, Any]] = None,
124124
doc_ui: bool = True,
125125
method: str = HTTPMethod.GET
126126
) -> ParametersTuple:

flask_openapi3/models/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#table-of-contents
1010
"""
1111

12-
from typing import Optional, List, Dict, Union
12+
from typing import Optional, Union
1313

1414
from flask import Request
1515
from pydantic import BaseModel
@@ -57,13 +57,13 @@ class APISpec(BaseModel):
5757
"""https://spec.openapis.org/oas/v3.1.0#openapi-object"""
5858
openapi: str
5959
info: Info
60-
servers: Optional[List[Server]] = None
60+
servers: Optional[list[Server]] = None
6161
paths: Paths
6262
components: Optional[Components] = None
63-
security: Optional[List[SecurityRequirement]] = None
64-
tags: Optional[List[Tag]] = None
63+
security: Optional[list[SecurityRequirement]] = None
64+
tags: Optional[list[Tag]] = None
6565
externalDocs: Optional[ExternalDocumentation] = None
66-
webhooks: Optional[Dict[str, Union[PathItem, Reference]]] = None
66+
webhooks: Optional[dict[str, Union[PathItem, Reference]]] = None
6767

6868
model_config = {
6969
"extra": "allow"
@@ -80,13 +80,13 @@ class OAuthConfig(BaseModel):
8080
appName: Optional[str] = None
8181
scopeSeparator: Optional[str] = None
8282
scopes: Optional[str] = None
83-
additionalQueryStringParams: Optional[Dict[str, str]] = None
83+
additionalQueryStringParams: Optional[dict[str, str]] = None
8484
useBasicAuthenticationWithAccessCodeGrant: Optional[bool] = False
8585
usePkceWithAuthorizationCodeGrant: Optional[bool] = False
8686

8787

8888
class RawModel(Request):
89-
mimetypes: List[str] = ["application/json"]
89+
mimetypes: list[str] = ["application/json"]
9090

9191

9292
Encoding.model_rebuild()

flask_openapi3/models/callback.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
# @Author : llc
33
# @Time : 2023/7/4 9:35
4-
from typing import TYPE_CHECKING, Dict
4+
from typing import TYPE_CHECKING
55

66
if TYPE_CHECKING: # pragma: no cover
77
from .path_item import PathItem
@@ -15,4 +15,4 @@
1515
The key value used to identify the path item object is an expression, evaluated at runtime,
1616
that identifies a URL to use for the callback operation.
1717
"""
18-
Callback = Dict[str, PathItem]
18+
Callback = dict[str, PathItem]

flask_openapi3/models/components.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
# @Author : llc
33
# @Time : 2023/7/4 9:36
4-
from typing import Dict, Optional, Union, Any
4+
from typing import Optional, Union, Any
55

66
from pydantic import BaseModel, Field
77

@@ -23,16 +23,16 @@ class Components(BaseModel):
2323
https://spec.openapis.org/oas/v3.1.0#components-object
2424
"""
2525

26-
schemas: Optional[Dict[str, Union[Reference, Schema]]] = Field(None)
27-
responses: Optional[Dict[str, Union[Response, Reference]]] = None
28-
parameters: Optional[Dict[str, Union[Parameter, Reference]]] = None
29-
examples: Optional[Dict[str, Union[Example, Reference]]] = None
30-
requestBodies: Optional[Dict[str, Union[RequestBody, Reference]]] = None
31-
headers: Optional[Dict[str, Union[Header, Reference]]] = None
32-
securitySchemes: Optional[Dict[str, Union[SecurityScheme, Dict[str, Any]]]] = None
33-
links: Optional[Dict[str, Union[Link, Reference]]] = None
34-
callbacks: Optional[Dict[str, Union[Callback, Reference]]] = None
35-
pathItems: Optional[Dict[str, Union[PathItem, Reference]]] = None
26+
schemas: Optional[dict[str, Union[Reference, Schema]]] = Field(None)
27+
responses: Optional[dict[str, Union[Response, Reference]]] = None
28+
parameters: Optional[dict[str, Union[Parameter, Reference]]] = None
29+
examples: Optional[dict[str, Union[Example, Reference]]] = None
30+
requestBodies: Optional[dict[str, Union[RequestBody, Reference]]] = None
31+
headers: Optional[dict[str, Union[Header, Reference]]] = None
32+
securitySchemes: Optional[dict[str, Union[SecurityScheme, dict[str, Any]]]] = None
33+
links: Optional[dict[str, Union[Link, Reference]]] = None
34+
callbacks: Optional[dict[str, Union[Callback, Reference]]] = None
35+
pathItems: Optional[dict[str, Union[PathItem, Reference]]] = None
3636

3737
model_config = {
3838
"extra": "allow"

flask_openapi3/models/discriminator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
# @Author : llc
33
# @Time : 2023/7/4 9:41
4-
from typing import Dict, Optional
4+
from typing import Optional
55

66
from pydantic import BaseModel
77

@@ -12,7 +12,7 @@ class Discriminator(BaseModel):
1212
"""
1313

1414
propertyName: str
15-
mapping: Optional[Dict[str, str]] = None
15+
mapping: Optional[dict[str, str]] = None
1616

1717
model_config = {
1818
"extra": "allow"

0 commit comments

Comments
 (0)