Skip to content

Commit 771b937

Browse files
committed
Update _unit.py
1 parent 4f4a081 commit 771b937

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

ecell4/extra/_unit.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,23 @@
99
from ..util import model_parser
1010

1111
import pint
12-
from pint.quantity import _Quantity
13-
from pint.unit import _Unit
14-
# from pint.errors import UndefinedUnitError
1512
from pint.errors import DimensionalityError
1613

14+
try:
15+
# Pint older versions (if still available)
16+
from pint.quantity import _Quantity # type: ignore
17+
from pint.unit import _Unit # type: ignore
18+
except ModuleNotFoundError:
19+
# Pint >= 0.20+: don't rely on private modules
20+
_Quantity = pint.Quantity # public API
21+
# Unit type isn't meant to be imported; keep for typing/export compatibility
22+
_Unit = object
23+
1724

1825
__all__ = [
19-
'getUnitRegistry', '_Quantity', '_Unit', 'wrap_quantity',
20-
'get_application_registry', 'check_model', 'DimensionalityMismatchError']
26+
'getUnitRegistry', '_Quantity', 'wrap_quantity',
27+
'get_application_registry', 'check_model', 'DimensionalityMismatchError'
28+
]
2129

2230
def wrapped_binary_operator(op1, op2):
2331
def wrapped(self, other):

0 commit comments

Comments
 (0)