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

Replace toml with tomllib #10

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ jobs:

steps:
- uses: actions/checkout@master
- name: Install Python dependencies
run: |
python -m pip install toml
- name: Install rust
run: |
rustup show
Expand Down
5 changes: 3 additions & 2 deletions generate_commands.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Copyright (C) 2023 Nitrokey GmbH
# SPDX-License-Identifier: LGPL-3.0-only

import toml
import sys
import tomllib

def capitilize_first(name):
name
Expand Down Expand Up @@ -84,7 +84,8 @@ def flatten(items):
exit(1)

outfile = open(sys.argv[2], "w")
data = toml.load(sys.argv[1])
with open(sys.argv[1], "rb") as infile:
data = tomllib.load(infile)

# REUSE-IgnoreStart
outfile.write("// Copyright (C) 2023 Nitrokey GmbH\n")
Expand Down
2 changes: 1 addition & 1 deletion src/se05x/commands.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ p2 = "P2_DEFAULT"

[scp_external_authenticate.payload]
then = [
{ name = "host_cryptogram", type = "[u8; 8]" }
{ name = "host_cryptogram", type = "[u8; 8]" },
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wait does that mean that the previous toml libraries accepted invalid input?

Copy link
Member Author

Choose a reason for hiding this comment

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

At least the generated file did not change. I haven’t looked into the details yet.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don’t see a good reason why toml would have accepted that. But it also looks like the package is not maintained anymore. So if we ever need toml support before Python 3.11 in the future, we should prefer tomli over toml.

{ name = "mac", type = "[u8; 8]" }
]

Expand Down
Loading