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

Support using built-in tomllib in Python 3.11 #654

Merged
merged 2 commits into from Dec 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions autopep8.py
Expand Up @@ -4018,13 +4018,16 @@ def read_config(args, parser):

def read_pyproject_toml(args, parser):
"""Read pyproject.toml and load configuration."""
import tomli
if sys.version_info >= (3, 11):
import tomllib
else:
import tomli as tomllib

config = None

if os.path.exists(args.global_config):
with open(args.global_config, "rb") as fp:
config = tomli.load(fp)
config = tomllib.load(fp)

if not args.ignore_local_config:
parent = tail = args.files and os.path.abspath(
Expand All @@ -4033,7 +4036,7 @@ def read_pyproject_toml(args, parser):
pyproject_toml = os.path.join(parent, "pyproject.toml")
if os.path.exists(pyproject_toml):
with open(pyproject_toml, "rb") as fp:
config = tomli.load(fp)
config = tomllib.load(fp)
break
(parent, tail) = os.path.split(parent)

Expand Down
2 changes: 1 addition & 1 deletion setup.py 100755 → 100644
Expand Up @@ -10,7 +10,7 @@


INSTALL_REQUIRES = (
['pycodestyle >= 2.10.0', 'tomli']
['pycodestyle >= 2.10.0', 'tomli; python_version < "3.11"']
)


Expand Down