Skip to content

type of context vars inconsistent based on line continuation #1490

@minrk

Description

@minrk

I'm working on a recipe with a derivative context variable that should be an integer. I'm discovering that if I split the expression using a multi-line continuation like >-, which produces the exact same parsed yaml, the resulting variable changes type from int to string.

Example:

context:
  build: 1
  build_plus: ${{ build + 1 }}
  build_plus_2: >-
    ${{ build + 1 }}

In the data structure, build_plus and build_plus_2 ought to be identical:

from ruamel.yaml import YAML

with open("recipe/recipe.yaml") as f:
    recipe = YAML().load(f)

recipe['context']['build_plus'] == recipe['context']['build_plus_2']

but in the computed context build_plus is an integer, while build_plus_2:

rattler-build build --render-only -r recipe | jq '.[0].recipe.context'`
{
  "build": 1,
  "build_plus": 2,
  "build_plus_2": "2",
}

I didn't expect splitting an expression across lines for readability without changing the yaml output to change the type of variables in the recipe.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions