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

use the standard library tomllib on sufficiently new python #2202

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions isort/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@
from .wrap_modes import from_string as wrap_mode_from_string

if TYPE_CHECKING:
tomli: Any
tomllib: Any
else:
from ._vendored import tomli
if sys.version_info >= (3, 11):
import tomllib

Check warning on line 51 in isort/settings.py

View check run for this annotation

Codecov / codecov/patch

isort/settings.py#L51

Added line #L51 was not covered by tests
else:
from ._vendored import tomli as tomllib

_SHEBANG_RE = re.compile(rb"^#!.*\bpython[23w]?\b")
CYTHON_EXTENSIONS = frozenset({"pyx", "pxd"})
Expand Down Expand Up @@ -831,7 +834,7 @@

if file_path.endswith(".toml"):
with open(file_path, "rb") as bin_config_file:
config = tomli.load(bin_config_file)
config = tomllib.load(bin_config_file)
for section in sections:
config_section = config
for key in section.split("."):
Expand Down
Loading