Skip to content

Commit f29d67f

Browse files
committed
compat
1 parent 5ddb893 commit f29d67f

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

pint/compat.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@
3131
else:
3232
from typing_extensions import deprecated # noqa
3333

34-
if sys.version_info >= (3, 11):
35-
import tomllib # noqa
36-
else:
37-
tomllib = None
38-
3934

4035
def missing_dependency(
4136
package: str, display_name: str | None = None
@@ -245,6 +240,20 @@ class BehaviorChangeWarning(UserWarning):
245240
except ImportError:
246241
HAS_DASK = False
247242

243+
try:
244+
import tomli_w # noqa: F401
245+
246+
HAS_TOMLLI_W = True
247+
except ImportError:
248+
HAS_TOMLLI_W = False
249+
250+
if sys.version_info >= (3, 11):
251+
import tomllib # noqa
252+
253+
HAS_TOMLLIB = True
254+
else:
255+
HAS_TOMLLIB = False
256+
248257

249258
##############################
250259
# Imports are handled here
@@ -253,6 +262,17 @@ class BehaviorChangeWarning(UserWarning):
253262
# in mypy configuration.
254263
##############################
255264

265+
if HAS_TOMLLIB:
266+
import tomllib # noqa: F401
267+
else:
268+
tomllib = None
269+
270+
if HAS_TOMLLI_W:
271+
import tomli_w # noqa: F401
272+
else:
273+
tomllib_w = None
274+
275+
256276
if HAS_BABEL:
257277
from babel import Locale
258278
from babel import units as babel_units

0 commit comments

Comments
 (0)