diff --git a/pyproject.toml b/pyproject.toml index 075b482..82b8244 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,7 @@ classifiers = [ ] dependencies = [ "click", - "toml", + "tomli; python_version < '3.11'", "colorama; platform_system == 'Windows'" ] diff --git a/spin/__main__.py b/spin/__main__.py index 194fa84..a718436 100644 --- a/spin/__main__.py +++ b/spin/__main__.py @@ -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 @@ -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)