Skip to content

Commit

Permalink
Use tomllib for python>=3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Nov 20, 2023
1 parent 07aff93 commit 1bae1a2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ classifiers = [
]
dependencies = [
"click",
"tomli",
"tomli ; python_version < '3.11'",
]

[project.urls]
Expand Down
9 changes: 9 additions & 0 deletions src/checklog_odoo/compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import sys

__all__ = ["tomllib"]


if sys.version_info >= (3, 11):
import tomllib
else:
import tomli as tomllib
5 changes: 3 additions & 2 deletions src/checklog_odoo/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from pathlib import Path

import click
import tomli

from .compat import tomllib

DEFAULT_CONFIG_FILE = "checklog.cfg"
SECTION = "checklog"
Expand Down Expand Up @@ -36,7 +37,7 @@ def __init__(self, filename):
pyproject_path = Path("pyproject.toml")
self.__pyproject = {}
if pyproject_path.is_file():
self.__pyproject = tomli.loads(pyproject_path.read_text())
self.__pyproject = tomllib.loads(pyproject_path.read_text())

@staticmethod
def add_default_map_reader(reader):
Expand Down

0 comments on commit 1bae1a2

Please sign in to comment.