Skip to content

The loader transforms 'on' key to True  #470

@adelbke

Description

@adelbke

I'm trying to parse a github Actions yaml file that has a key named 'on' like shown below:

candidate.yaml

name: action code

on: # this is the key causing the issue, it's translated to 'True' when loaded by pyyaml
  push:
    branches:
      - master

jobs:
  build:

    runs-on: ubuntu-16.04

    steps:
# Action Steps

tested on:
Python version: 3.8.6
Ubuntu 20.10

here's the code used:

import yaml
# candidate.yaml is the name of the file up above
data = yaml.load(open('candidate.yaml','r'))
print(yaml.dump(data))

here's the output:

name: action code)
true: # here it says 'true' instead of 'on' in the original file
  push:
    branches:
    - master
jobs:
  build:
    runs-on: ubuntu-16.04
    steps: null

as you can see the 'on' key has been replaced by 'True' on this file

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions