Skip to content

Commit

Permalink
DEP: migrate from toml package to tomllib (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros authored Jul 17, 2023
1 parent 027269a commit 56c3682
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
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

0 comments on commit 56c3682

Please sign in to comment.