Skip to content

Commit d6fb2c1

Browse files
committed
style: fix linting issues in examples and tests
1 parent 058220c commit d6fb2c1

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

examples/event_handler/upload_file_example.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
file handling and proper OpenAPI schema generation.
66
"""
77

8-
from typing_extensions import Annotated, List
8+
from typing_extensions import Annotated
99

1010
from aws_lambda_powertools.event_handler import APIGatewayRestResolver
1111
from aws_lambda_powertools.event_handler.openapi.params import File, Form, UploadFile
@@ -17,7 +17,7 @@
1717
def upload_file(file: Annotated[UploadFile, File()]):
1818
"""
1919
Upload a single file.
20-
20+
2121
Returns file metadata and a preview of the content.
2222
"""
2323
return {
@@ -36,7 +36,7 @@ def upload_multiple_files(
3636
):
3737
"""
3838
Upload multiple files with form data.
39-
39+
4040
Shows how to mix UploadFile, bytes files, and form data in the same endpoint.
4141
"""
4242
return {
@@ -54,7 +54,7 @@ def upload_multiple_files(
5454
def upload_with_headers(file: Annotated[UploadFile, File()]):
5555
"""
5656
Upload a file and access its headers.
57-
57+
5858
Demonstrates how to access all headers from the multipart section.
5959
"""
6060
return {
@@ -73,7 +73,3 @@ def handler(event, context):
7373
# Print the OpenAPI schema for testing
7474
schema = app.get_openapi_schema(title="File Upload API", version="1.0.0")
7575
print("\n✅ OpenAPI schema generated successfully!")
76-
77-
# You can access the schema as JSON with:
78-
# import json
79-
# print(json.dumps(schema.model_dump(), indent=2))

tests/functional/event_handler/_pydantic/test_uploadfile_openapi_schema.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import pytest
21
import json
2+
33
from typing_extensions import Annotated
44

55
from aws_lambda_powertools.event_handler import APIGatewayRestResolver
@@ -35,7 +35,7 @@ def upload_multiple_files(
3535

3636
# Generate OpenAPI schema
3737
schema = app.get_openapi_schema()
38-
38+
3939
# Print schema for debugging
4040
schema_dict = schema.model_dump()
4141
print("SCHEMA PATHS:")
@@ -46,27 +46,28 @@ def upload_multiple_files(
4646
if "content" in path_item["post"]["requestBody"]:
4747
if "multipart/form-data" in path_item["post"]["requestBody"]["content"]:
4848
print(" Found multipart/form-data")
49-
print(f" Schema: {json.dumps(path_item['post']['requestBody']['content']['multipart/form-data'], indent=2)}")
50-
49+
content = path_item["post"]["requestBody"]["content"]["multipart/form-data"]
50+
print(f" Schema: {json.dumps(content, indent=2)}")
51+
5152
print("\nSCHEMA COMPONENTS:")
5253
if "components" in schema_dict and "schemas" in schema_dict["components"]:
5354
for name, comp_schema in schema_dict["components"]["schemas"].items():
5455
if "file" in name.lower() or "upload" in name.lower():
5556
print(f"Component: {name}")
5657
print(f" {json.dumps(comp_schema, indent=2)}")
57-
58+
5859
# Basic verification
5960
paths = schema.paths
6061
assert "/upload-single" in paths
6162
assert "/upload-multiple" in paths
62-
63+
6364
# Verify upload-single endpoint exists
6465
upload_single = paths["/upload-single"]
6566
assert upload_single.post is not None
66-
67+
6768
# Verify upload-multiple endpoint exists
6869
upload_multiple = paths["/upload-multiple"]
6970
assert upload_multiple.post is not None
70-
71+
7172
# Print success
7273
print("\n✅ Basic OpenAPI schema generation tests passed")

0 commit comments

Comments
 (0)