Skip to content

Commit 2af45cd

Browse files
committed
chore(golden): apply black --target-version py310 formatting
CI's black-check runs against Python 3.10 and rejected the formatting written by black running under Python 3.13 (the venv's interpreter), which preferred longer single-line function signatures that 3.10's parser couldn't accept. Re-running black with an explicit --target-version py310 collapses the affected lines back to the multi-line shape CI accepts. Pure formatting; no behavior change. 37/37 tests still pass.
1 parent a668286 commit 2af45cd

4 files changed

Lines changed: 9 additions & 24 deletions

File tree

tests/golden/check_semver_bump.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,7 @@ def check(
9898

9999
def _read_version_at_ref(ref: str) -> str:
100100
"""Read __version__ from samcli/__init__.py at a git ref."""
101-
out = subprocess.check_output(
102-
["git", "show", f"{ref}:samcli/__init__.py"], text=True
103-
)
101+
out = subprocess.check_output(["git", "show", f"{ref}:samcli/__init__.py"], text=True)
104102
m = re.search(r'__version__\s*=\s*"([^"]+)"', out)
105103
if not m:
106104
raise RuntimeError(f"cannot find __version__ at {ref}")
@@ -109,9 +107,7 @@ def _read_version_at_ref(ref: str) -> str:
109107

110108
def _git_changed_files(base: str, head: str) -> List[Change]:
111109
"""Return all files changed between base and head with their git status."""
112-
out = subprocess.check_output(
113-
["git", "diff", "--name-status", f"{base}...{head}"], text=True
114-
)
110+
out = subprocess.check_output(["git", "diff", "--name-status", f"{base}...{head}"], text=True)
115111
changes: List[Change] = []
116112
for line in out.splitlines():
117113
if not line.strip():

tests/golden/harness.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,7 @@ def run_build_pipeline(template_path: Path, language_extensions: bool) -> Dict[s
284284

285285
parameter_values = dict(IntrinsicsSymbolTable.DEFAULT_PSEUDO_PARAM_VALUES)
286286

287-
le_result = expand_language_extensions(
288-
template, parameter_values=parameter_values, enabled=language_extensions
289-
)
287+
le_result = expand_language_extensions(template, parameter_values=parameter_values, enabled=language_extensions)
290288
expanded = copy.deepcopy(le_result.expanded_template)
291289

292290
transformed = _run_sam_transform(expanded, parameter_values)
@@ -376,15 +374,11 @@ def _rewrite_artifacts_to_s3(template: Dict[str, Any], uploader, template_dir: s
376374
if not isinstance(rtype, str):
377375
# _walk_artifact_properties already filters, but re-narrow for mypy.
378376
continue
379-
replacement = _packageable_replacement(
380-
rtype, prop_path, current, template_dir, resource_id
381-
)
377+
replacement = _packageable_replacement(rtype, prop_path, current, template_dir, resource_id)
382378
_set_at_path(resource, prop_path, replacement)
383379

384380

385-
def _packageable_replacement(
386-
rtype: str, prop_path: str, current: Any, template_dir: str, resource_id: str
387-
) -> Any:
381+
def _packageable_replacement(rtype: str, prop_path: str, current: Any, template_dir: str, resource_id: str) -> Any:
388382
"""Compute the deterministic replacement for an artifact property.
389383
390384
Returns either a dict ({"S3Bucket": ..., "S3Key": ...}) or a string
@@ -402,9 +396,7 @@ def _packageable_replacement(
402396
- AWS::Serverless::Function .CodeUri (post-transform = Lambda::Function .Code, handled above)
403397
- All other artifact properties -> "s3://<bucket>/<sha256>"
404398
"""
405-
digest = hashlib.sha256(
406-
f"{current}|{rtype}|{prop_path}|{resource_id}".encode("utf-8")
407-
).hexdigest()
399+
digest = hashlib.sha256(f"{current}|{rtype}|{prop_path}|{resource_id}".encode("utf-8")).hexdigest()
408400
# Lambda image — must check before the .Code dict shape
409401
if rtype == "AWS::Lambda::Function" and prop_path == "Code.ImageUri":
410402
return f"{GOLDEN_BUCKET}.dkr.ecr.us-east-1.amazonaws.com/golden:{digest[:12]}"

tests/golden/test_corpus.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ def _hint(case_dir: Path) -> str:
2424
def test_build_output_matches_golden(golden_case):
2525
meta = _read_metadata(golden_case)
2626
le_enabled = _resolve_le_default(golden_case, meta)
27-
actual = normalize(
28-
run_build_pipeline(golden_case / "template.yaml", language_extensions=le_enabled)
29-
)
27+
actual = normalize(run_build_pipeline(golden_case / "template.yaml", language_extensions=le_enabled))
3028
expected_path = golden_case / "expected.build.yaml"
3129
assert expected_path.exists(), f"missing {expected_path}; run update_goldens.py --new"
3230
expected = expected_path.read_text(encoding="utf-8")
@@ -36,9 +34,7 @@ def test_build_output_matches_golden(golden_case):
3634
def test_package_output_matches_golden(golden_case):
3735
meta = _read_metadata(golden_case)
3836
le_enabled = _resolve_le_default(golden_case, meta)
39-
build_out = run_build_pipeline(
40-
golden_case / "template.yaml", language_extensions=le_enabled
41-
)
37+
build_out = run_build_pipeline(golden_case / "template.yaml", language_extensions=le_enabled)
4238
actual = normalize(run_package_pipeline(golden_case / "template.yaml", build_out))
4339
expected_path = golden_case / "expected.package.yaml"
4440
assert expected_path.exists(), f"missing {expected_path}; run update_goldens.py --new"

tests/golden/test_normalize.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def test_normalize_is_idempotent():
5757
template = {"Resources": {"A": {"Type": "T"}}}
5858
once = normalize(template)
5959
import yaml
60+
6061
twice = normalize(yaml.safe_load(once))
6162
assert once == twice
6263

0 commit comments

Comments
 (0)