Skip to content

Commit

Permalink
Merge pull request #354 from twisted/swap-toml-with-tomli
Browse files Browse the repository at this point in the history
swap toml with tomli
  • Loading branch information
graingert committed Jul 7, 2021
2 parents 61681d6 + 322d3eb commit 5dce0fa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
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'",
],
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, 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
@@ -0,0 +1 @@
Support Toml v1 syntax with tomli on Python 3.6+

0 comments on commit 5dce0fa

Please sign in to comment.