Skip to content

Commit

Permalink
Migrate to tomli
Browse files Browse the repository at this point in the history
Closes #137.
  • Loading branch information
fsouza committed Sep 6, 2022
1 parent 9fd81fb commit 67ee42e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions autoflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -1089,9 +1089,13 @@ def find_files(filenames, recursive, exclude):

def process_pyproject_toml(toml_file_path):
"""Extract config mapping from pyproject.toml file."""
import toml
try:
import tomllib
except ModuleNotFoundError:
import tomli as tomllib

return toml.load(toml_file_path).get("tool", {}).get("autoflake", None)
with open(toml_file_path, "rb") as f:
return tomllib.load(f).get("tool", {}).get("autoflake", None)


def process_setup_cfg(cfg_file_path):
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ py_modules =
autoflake
install_requires =
pyflakes>=1.1.0
toml>=0.10.2
tomli>=2.0.1;python_version<'3.11'
python_requires = >=3.7
test_suite = test_autoflake

Expand Down

0 comments on commit 67ee42e

Please sign in to comment.