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
Original file line number Diff line number Diff line change
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'",
],
extras_require={"dev": ["packaging"]},
package_dir={"": "src"},
packages=find_packages("src"),
Expand Down
12 changes: 9 additions & 3 deletions src/towncrier/_settings.py
Original file line number Diff line number Diff line change
@@ -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, 6):
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 io.open(config_file, "r", encoding="utf8") as conffile:
config = _toml_load(conffile)

return parse_toml(directory, config)

Expand Down
1 change: 1 addition & 0 deletions src/towncrier/newsfragments/354.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Support Toml v1 syntax with tomli on Python 3.6+