From 4321df1bea36ea6d28a76f981b34a6e269f1e583 Mon Sep 17 00:00:00 2001
From: Alexandre Detiste <alexandre.detiste@gmail.com>
Date: Sat, 17 May 2025 17:21:55 +0200
Subject: [PATCH] tomli is part of the Python standard library since Py3.11

tomli and tomllib are the samething,
usage of old tomli will slowly fade away
---
 .hooks/make_release_commit.py | 7 +++++--
 taskipy/pyproject.py          | 9 ++++++---
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/.hooks/make_release_commit.py b/.hooks/make_release_commit.py
index 0c4b3a7..5d6dbb5 100644
--- a/.hooks/make_release_commit.py
+++ b/.hooks/make_release_commit.py
@@ -1,5 +1,8 @@
 #!/usr/bin/env python3
-import tomli
+try:
+    import tomllib
+except ImportError:
+    import tomli as tomllib
 import secrets
 import subprocess
 import webbrowser
@@ -9,7 +12,7 @@
 def create_release_commit():
     cwd = Path.cwd()
     with open(cwd / "pyproject.toml", "rb") as file:
-        pyproject = tomli.load(file)
+        pyproject = tomllib.load(file)
     version = pyproject["tool"]["poetry"]["version"]
     branch = f"release-{version}-{secrets.token_hex(12)}"
 
diff --git a/taskipy/pyproject.py b/taskipy/pyproject.py
index e7fd74e..d37ca30 100644
--- a/taskipy/pyproject.py
+++ b/taskipy/pyproject.py
@@ -1,4 +1,7 @@
-import tomli
+try:
+    import tomllib
+except ImportError:
+    import tomli as tomllib
 
 from pathlib import Path
 from typing import Any, Dict, MutableMapping, Optional, Union
@@ -92,10 +95,10 @@ def __load_toml_file(file_path: Union[str, Path]) -> MutableMapping[str, Any]:
                 file_path = Path(file_path).resolve()
 
             with open(file_path, 'rb') as file:
-                return tomli.load(file)
+                return tomllib.load(file)
         except FileNotFoundError:
             raise MissingPyProjectFileError()
-        except tomli.TOMLDecodeError as e:
+        except tomllib.TOMLDecodeError as e:
             raise MalformedPyProjectError(reason=str(e))
 
     @staticmethod
