Skip to content

Commit

Permalink
🎨Move tomllib access to _compat @ packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
webknjaz committed Nov 28, 2023
1 parent b3a5a71 commit 6e61b44
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 7 additions & 1 deletion packaging/pep517_backend/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,10 @@ def chdir_cm(path: os.PathLike) -> t.Iterator[None]:
os.chdir(original_wd)


__all__ = ("chdir_cm",) # noqa: WPS410
try:
from tomllib import loads as load_toml_from_string
except ImportError:
from tomli import loads as load_toml_from_string # type: ignore[no-redef]


__all__ = ("chdir_cm", "load_toml_from_string") # noqa: WPS410
8 changes: 2 additions & 6 deletions packaging/pep517_backend/_cython_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@

from expandvars import expandvars

try:
from tomllib import loads as _load_toml_from_string
except ImportError:
from tomli import loads as _load_toml_from_string # type: ignore[no-redef]

from ._compat import load_toml_from_string # noqa: WPS436
from ._transformers import ( # noqa: WPS436
get_cli_kwargs_from_config,
get_enabled_cli_flags_from_config,
Expand Down Expand Up @@ -73,7 +69,7 @@ def get_local_cython_config() -> dict:
# NAME = "VALUE"
"""
config_toml_txt = (Path.cwd().resolve() / 'pyproject.toml').read_text()
config_mapping = _load_toml_from_string(config_toml_txt)
config_mapping = load_toml_from_string(config_toml_txt)
return config_mapping['tool']['local']['cythonize']


Expand Down

0 comments on commit 6e61b44

Please sign in to comment.