Skip to content

feat(step-generation): more compact Python generation for dicts#18592

Merged
ddcc4 merged 4 commits intochore_release-pd-8.5.0from
dc-pdpy-format-dict
Jun 13, 2025
Merged

feat(step-generation): more compact Python generation for dicts#18592
ddcc4 merged 4 commits intochore_release-pd-8.5.0from
dc-pdpy-format-dict

Conversation

@ddcc4
Copy link
Copy Markdown
Contributor

@ddcc4 ddcc4 commented Jun 10, 2025

Overview

The custom liquid class dict for define_liquid_class() is kind of big. This PR makes the dict formatting a bit more compact: if all the entries in the dict are scalar, and their total length is short-ish, we will emit the dict on a single line.

Before:

"offset": {
    "x": 1,
    "y": 0,
    "z": 5,
},

After:

"offset": {"x": 1, "y": 0, "z": 5},

(See tests for other examples.)

This PR also cleans up the code for emitting lists of pairs as Python tuples that was introduced in PR #18558.

Test Plan and Hands on Testing

Added/updated unit tests.

Risk assessment

Low.

@ddcc4 ddcc4 requested a review from jerader June 10, 2025 22:46
@ddcc4 ddcc4 requested a review from a team as a code owner June 10, 2025 22:46
@ddcc4
Copy link
Copy Markdown
Contributor Author

ddcc4 commented Jun 10, 2025

@jerader If you want to merge your PR first, I'll wait for your PR and fix up all the merge/test conflicts myself.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 23.65%. Comparing base (51d3169) to head (76434e0).
Report is 5 commits behind head on chore_release-pd-8.5.0.

Additional details and impacted files

Impacted file tree graph

@@                    Coverage Diff                     @@
##           chore_release-pd-8.5.0   #18592      +/-   ##
==========================================================
- Coverage                   25.85%   23.65%   -2.20%     
==========================================================
  Files                        3278     3233      -45     
  Lines                      284084   279692    -4392     
  Branches                    28584    27929     -655     
==========================================================
- Hits                        73440    66159    -7281     
- Misses                     210617   213506    +2889     
  Partials                       27       27              
Flag Coverage Δ
protocol-designer 19.08% <100.00%> (-0.12%) ⬇️
step-generation 4.81% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
step-generation/src/utils/liquidClassUtils.ts 99.46% <100.00%> (-0.54%) ⬇️
step-generation/src/utils/pythonFormat.ts 82.57% <100.00%> (+1.47%) ⬆️

... and 254 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

}

/** Render an array value as a Python tuple. */
export function formatPyTuple(list: any[]): string {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes more sense to have a separate fn for this, thanks!

Copy link
Copy Markdown
Collaborator

@jerader jerader left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this decreases the number of lines for the custom liquid class properties by a lot. thanks!

@jerader
Copy link
Copy Markdown
Collaborator

jerader commented Jun 11, 2025

@jerader If you want to merge your PR first, I'll wait for your PR and fix up all the merge/test conflicts myself.

@ddcc4 cool, i'll merge mine in then - thanks!

@ddcc4 ddcc4 requested a review from a team as a code owner June 13, 2025 16:43
@ddcc4 ddcc4 requested review from ncdiehl11 and removed request for a team June 13, 2025 16:43
@ddcc4 ddcc4 merged commit 71e6b93 into chore_release-pd-8.5.0 Jun 13, 2025
30 checks passed
@ddcc4 ddcc4 deleted the dc-pdpy-format-dict branch June 13, 2025 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants