Skip to content

Commit

Permalink
Use tomllib on Python 3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
jwodder committed Oct 25, 2022
1 parent 9f156f6 commit b4d8602
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ v0.4.0 (in development)
-----------------------
- Drop support for Python 3.6
- Support Python 3.11
- Use `tomllib` on Python 3.11

v0.3.2 (2022-09-03)
-------------------
Expand Down
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ v0.4.0 (in development)
-----------------------
- Drop support for Python 3.6
- Support Python 3.11
- Use `tomllib` on Python 3.11

v0.3.2 (2022-09-03)
-------------------
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ install_requires =
platformdirs ~= 2.1
pydantic ~= 1.7
python-dotenv ~= 0.11
tomli >= 1.2, < 3.0
tomli >= 1.2, < 3.0; python_version < "3.11"
typing_extensions; python_version < "3.8"

[options.packages.find]
Expand Down
8 changes: 6 additions & 2 deletions src/outgoing/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@
from types import TracebackType
from typing import Any, Optional, TypeVar, cast
from platformdirs import user_config_path
import tomli
from . import errors
from .util import AnyPath

if sys.version_info[:2] >= (3, 11):
from tomllib import load as toml_load
else:
from tomli import load as toml_load

if sys.version_info[:2] >= (3, 10):
from importlib.metadata import entry_points
else:
Expand Down Expand Up @@ -97,7 +101,7 @@ def from_config_file(
try:
if configpath.suffix == ".toml":
with configpath.open("rb") as fb:
data = tomli.load(fb)
data = toml_load(fb)
elif configpath.suffix == ".json":
with configpath.open("r") as fp:
data = json.load(fp)
Expand Down

0 comments on commit b4d8602

Please sign in to comment.