Skip to content

Commit

Permalink
Merge pull request #2202 from eli-schwartz/tomllib
Browse files Browse the repository at this point in the history
use the standard library tomllib on sufficiently new python
  • Loading branch information
staticdev authored Dec 4, 2023
2 parents b67a6a5 + 0c20647 commit f61affa
Showing 1 changed file with 6 additions and 3 deletions.
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
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 @@ def _get_config_data(file_path: str, sections: Tuple[str, ...]) -> Dict[str, Any

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

0 comments on commit f61affa

Please sign in to comment.