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

DEP: migrate from toml package to tomllib #93

Merged
merged 1 commit into from
Jul 17, 2023
Merged
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ classifiers = [
]
dependencies = [
"click",
"toml",
"tomli; python_version < '3.11'",
"colorama; platform_system == 'Windows'"
]

Expand Down
12 changes: 8 additions & 4 deletions spin/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
import sys

import click
import toml

from spin import cmds as _cmds
from spin.color_format import ColorHelpFormatter
from spin.sectioned_help import SectionedHelpGroup

if sys.version_info >= (3, 11):
import tomllib
else:
import tomli as tomllib

click.Context.formatter_class = ColorHelpFormatter


Expand Down Expand Up @@ -41,10 +45,10 @@ def main():
print("Error: cannot find [pyproject.toml]")
sys.exit(1)

with open("pyproject.toml") as f:
with open("pyproject.toml", "rb") as f:
try:
toml_config = toml.load(f)
except:
toml_config = tomllib.load(f)
except tomllib.TOMLDecodeError:
print("Cannot parse [pyproject.toml]")
sys.exit(1)

Expand Down