diff --git a/autopep8.py b/autopep8.py index da427ecb..27809fc9 100755 --- a/autopep8.py +++ b/autopep8.py @@ -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( @@ -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) diff --git a/setup.py b/setup.py old mode 100755 new mode 100644 index ba5c8f31..9e48162e --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ INSTALL_REQUIRES = ( - ['pycodestyle >= 2.10.0', 'tomli'] + ['pycodestyle >= 2.10.0', 'tomli; python_version < "3.11"'] )