Skip to content

Commit a4477c3

Browse files
committed
Fix static analysis issues
- Add ruff configuration to allow print statements in examples scripts - Fix code formatting in deploy.py
1 parent abba080 commit a4477c3

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

examples/deploy.py

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,27 @@ def create_deployment_package(example_name: str) -> Path:
3434
package_dir.mkdir()
3535

3636
# Install dependencies
37-
subprocess.run([
38-
sys.executable, "-m", "pip", "install",
39-
"-t", str(package_dir),
40-
"aws_durable_execution_sdk_python"
41-
], check=True)
37+
subprocess.run(
38+
[
39+
sys.executable,
40+
"-m",
41+
"pip",
42+
"install",
43+
"-t",
44+
str(package_dir),
45+
"aws_durable_execution_sdk_python",
46+
],
47+
check=True,
48+
)
4249

4350
# Copy example source
4451
src_file = Path(__file__).parent / "src" / f"{example_name}.py"
4552
(package_dir / f"{example_name}.py").write_text(src_file.read_text())
4653

4754
# Create zip
4855
zip_path = Path(__file__).parent / f"{example_name}.zip"
49-
with zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED) as zf:
50-
for file_path in package_dir.rglob('*'):
56+
with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as zf:
57+
for file_path in package_dir.rglob("*"):
5158
if file_path.is_file():
5259
zf.write(file_path, file_path.relative_to(package_dir))
5360

@@ -82,9 +89,7 @@ def deploy_function(example_config: dict, function_name: str):
8289

8390
# Use regular lambda client for now
8491
lambda_client = boto3.client(
85-
"lambda",
86-
endpoint_url=lambda_endpoint,
87-
region_name=region
92+
"lambda", endpoint_url=lambda_endpoint, region_name=region
8893
)
8994

9095
role_arn = f"arn:aws:iam::{account_id}:role/DurableFunctionsIntegrationTestRole"
@@ -98,11 +103,7 @@ def deploy_function(example_config: dict, function_name: str):
98103
"Description": example_config["description"],
99104
"Timeout": 60,
100105
"MemorySize": 128,
101-
"Environment": {
102-
"Variables": {
103-
"DEX_ENDPOINT": lambda_endpoint
104-
}
105-
}
106+
"Environment": {"Variables": {"DEX_ENDPOINT": lambda_endpoint}},
106107
# TODO: Add DurableConfig support
107108
# "DurableConfig": example_config["durableConfig"]
108109
}
@@ -121,8 +122,7 @@ def deploy_function(example_config: dict, function_name: str):
121122

122123
# Update code
123124
lambda_client.update_function_code(
124-
FunctionName=function_name,
125-
ZipFile=zip_content
125+
FunctionName=function_name, ZipFile=zip_content
126126
)
127127

128128
# Update configuration
@@ -132,18 +132,15 @@ def deploy_function(example_config: dict, function_name: str):
132132
print(f"Creating new function: {function_name}")
133133

134134
# Create function
135-
lambda_client.create_function(
136-
**function_config,
137-
Code={"ZipFile": zip_content}
138-
)
135+
lambda_client.create_function(**function_config, Code={"ZipFile": zip_content})
139136

140137
# Add invoke permission
141138
try:
142139
lambda_client.add_permission(
143140
FunctionName=function_name,
144141
StatementId="dex-invoke-permission",
145142
Action="lambda:InvokeFunction",
146-
Principal=invoke_account_id
143+
Principal=invoke_account_id,
147144
)
148145
print("Added invoke permission")
149146
except lambda_client.exceptions.ResourceConflictException:

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ lines-after-imports = 2
133133
"SIM117",
134134
"TRY301",
135135
]
136+
"examples/*.py" = [
137+
"T201", # Allow print statements in deployment scripts
138+
"PLR2004", # Allow magic values in deployment scripts
139+
]
136140
"src/aws_durable_execution_sdk_python_testing/invoker.py" = [
137141
"A002", # Argument `input` is shadowing a Python builtin
138142
]

0 commit comments

Comments
 (0)