Skip to content

Commit

Permalink
Use tomli to read .toml files (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgorny authored Mar 31, 2022
1 parent 95ec0ea commit ba0d497
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ repos:
- types-mock
- types-setuptools
- types-docutils
- types-toml
- repo: https://github.com/PyCQA/pylint
rev: v2.13.3
hooks:
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ instead.
* ``$CWD/tox.ini``
* ``$CWD/pep8.ini``
* ``$CWD/setup.cfg``
* ``$CWD/pyproject.toml`` in section ``[tool.doc8]`` if ``toml`` is installed
* ``$CWD/pyproject.toml`` in section ``[tool.doc8]`` if ``tomli`` is installed

An example section that can be placed into one of these files::

Expand Down
5 changes: 3 additions & 2 deletions src/doc8/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import sys

try:
import toml
import tomli

HAVE_TOML = True
except ImportError:
Expand Down Expand Up @@ -134,7 +134,8 @@ def from_ini(fp):


def from_toml(fp):
cfg = toml.load(fp).get("tool", {}).get("doc8", {})
with open(fp, "rb") as f:
cfg = tomli.load(f).get("tool", {}).get("doc8", {})
return cfg


Expand Down
2 changes: 1 addition & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
mock # BSD
pytest # MIT
toml # MIT
tomli # MIT

0 comments on commit ba0d497

Please sign in to comment.