Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swap toml with tomli #354

Merged
merged 13 commits into from Jul 7, 2021
10 changes: 9 additions & 1 deletion setup.py
Expand Up @@ -41,7 +41,15 @@
"Programming Language :: Python :: Implementation :: PyPy",
],
use_incremental=True,
install_requires=["click", "click-default-group", "incremental", "jinja2", "setuptools", "toml"],
install_requires=[
"click",
"click-default-group",
"incremental",
"jinja2",
"setuptools",
"toml; python_version < '3.6'",
"tomli; python_version > '3.6'",
graingert marked this conversation as resolved.
Show resolved Hide resolved
],
extras_require={"dev": ["packaging"]},
package_dir={"": "src"},
packages=find_packages("src"),
Expand Down
12 changes: 9 additions & 3 deletions src/towncrier/_settings.py
@@ -1,9 +1,15 @@
# Copyright (c) Amber Brown, 2015
# See LICENSE for details.

import io
import os
import sys
import pkg_resources
import toml

if sys.version_info > (3, 5):
graingert marked this conversation as resolved.
Show resolved Hide resolved
from tomli import load as _toml_load
else:
from toml import load as _toml_load

from collections import OrderedDict

Expand Down Expand Up @@ -69,8 +75,8 @@ def load_config(directory):

def load_config_from_file(directory, config_file):

with open(config_file, "r") as conffile:
config = toml.load(conffile)
with open(config_file, "r", encoding="utf8") as conffile:
graingert marked this conversation as resolved.
Show resolved Hide resolved
config = _toml_load(conffile)

return parse_toml(directory, config)

Expand Down