Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read YAML and output TOML #180

Closed
Karmaki opened this issue Feb 29, 2024 · 6 comments
Closed

Read YAML and output TOML #180

Karmaki opened this issue Feb 29, 2024 · 6 comments

Comments

@Karmaki
Copy link

Karmaki commented Feb 29, 2024

I was wondering if there is a way to take a YAML file as input, and output a TOML file? Since you are handling both formats, I thought it should be possible, but if it is, I do not find how.

Thanks in advance for your answer, and thanks for your nice tool.

@kislyuk
Copy link
Owner

kislyuk commented Mar 1, 2024

Try this:

cat pyproject.toml | tomlq --yaml-output . > pyproject.yaml
cat pyproject.yaml | yq --toml-output . > pyproject.toml

@Karmaki
Copy link
Author

Karmaki commented Mar 1, 2024

Thank you very much for your answer.

I missed --toml-output option because it is not listed in my yq --help, and indeed, cat pyproject.yaml | yq . is OK, but with --toml-output, I get:

yq: Error running jq: _ConvertError: Invalid type <class 'NoneType'>.

My version is:

$ yq --version
yq 3.2.3

Maybe this is a new option?

@kislyuk
Copy link
Owner

kislyuk commented Mar 1, 2024

The option is undocumented on purpose. It has been there for as long as TOML support has been there.

Can you paste the contents of your pyproject.toml?

@kislyuk
Copy link
Owner

kislyuk commented Mar 1, 2024

Ah, I think I know what's happening there. You are trying to convert a YAML file with null values into TOML, which does not support them.

@kislyuk
Copy link
Owner

kislyuk commented Mar 1, 2024

Filed #183

I'm going to close this issue since there is no bug that I can identify aside from that.

@kislyuk kislyuk closed this as completed Mar 1, 2024
@Karmaki
Copy link
Author

Karmaki commented Mar 8, 2024

Sorry for the delay of my answer. Indeed, this was the problem. Thank you very much for your answer and for the new ticket.

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

No branches or pull requests

2 participants