|
43 | 43 | import copy |
44 | 44 | import hashlib |
45 | 45 | from pathlib import Path |
46 | | -from typing import Any, Dict, List |
| 46 | +from typing import Any, Dict, List, Optional |
47 | 47 |
|
48 | 48 | import yaml |
49 | 49 |
|
@@ -72,6 +72,8 @@ def _walk_artifact_properties(template: Dict[str, Any]) -> List: |
72 | 72 | if not isinstance(resource, dict): |
73 | 73 | continue |
74 | 74 | rtype = resource.get("Type") |
| 75 | + if not isinstance(rtype, str): |
| 76 | + continue |
75 | 77 | for prop_paths in ( |
76 | 78 | RESOURCES_WITH_LOCAL_PATHS.get(rtype, []), |
77 | 79 | RESOURCES_WITH_IMAGE_COMPONENT.get(rtype, []), |
@@ -236,11 +238,12 @@ def _run_sam_transform(template: Dict[str, Any], parameter_values: Dict[str, Any |
236 | 238 | boto_session=None, |
237 | 239 | ) |
238 | 240 |
|
239 | | - return sam_translator.translate( |
| 241 | + translated: Dict[str, Any] = sam_translator.translate( |
240 | 242 | sam_template=template_copy, |
241 | 243 | parameter_values=parameter_values, |
242 | 244 | get_managed_policy_map=lambda: {}, |
243 | 245 | ) |
| 246 | + return translated |
244 | 247 |
|
245 | 248 |
|
246 | 249 | def run_build_pipeline(template_path: Path, language_extensions: bool) -> Dict[str, Any]: |
@@ -279,21 +282,24 @@ def __init__(self, template_dir: str): |
279 | 282 | self.bucket_name = GOLDEN_BUCKET |
280 | 283 | self.no_progressbar = True |
281 | 284 |
|
282 | | - def upload(self, file_name: str, key: str = None) -> str: |
| 285 | + def upload(self, file_name: str, key: Optional[str] = None) -> str: |
283 | 286 | # Hash the file content so the URI is content-addressed. |
284 | 287 | with open(file_name, "rb") as f: |
285 | 288 | digest = hashlib.sha256(f.read()).hexdigest() |
286 | 289 | return f"s3://{GOLDEN_BUCKET}/{digest}" |
287 | 290 |
|
288 | 291 | def upload_with_dedup( |
289 | | - self, file_name: str, extension: str = None, precomputed_md5: str = None |
| 292 | + self, |
| 293 | + file_name: str, |
| 294 | + extension: Optional[str] = None, |
| 295 | + precomputed_md5: Optional[str] = None, |
290 | 296 | ) -> str: |
291 | 297 | return self.upload(file_name) |
292 | 298 |
|
293 | 299 | def file_exists(self, key: str) -> bool: |
294 | 300 | return False |
295 | 301 |
|
296 | | - def to_path_style_s3_url(self, key: str, version: str = None) -> str: |
| 302 | + def to_path_style_s3_url(self, key: str, version: Optional[str] = None) -> str: |
297 | 303 | return f"https://s3.amazonaws.com/{GOLDEN_BUCKET}/{key}" |
298 | 304 |
|
299 | 305 | def get_version_of_artifact(self, s3_url: str): |
|
0 commit comments