Skip to content

Commit 8a47cb4

Browse files
authored
Lazy imports for Python 3.15+ (#335)
1 parent 823ad60 commit 8a47cb4

4 files changed

Lines changed: 15 additions & 0 deletions

File tree

src/humanize/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
from __future__ import annotations
44

5+
__lazy_modules__ = {
6+
"humanize._version",
7+
"humanize.filesize",
8+
"humanize.i18n",
9+
"humanize.lists",
10+
"humanize.number",
11+
"humanize.time",
12+
}
13+
514
from humanize.filesize import naturalsize
615
from humanize.i18n import activate, deactivate, decimal_separator, thousands_separator
716
from humanize.lists import natural_list

src/humanize/filesize.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from __future__ import annotations
44

5+
__lazy_modules__ = {"humanize.i18n", "math"}
6+
57
from math import log
68

79
from humanize.i18n import _gettext as _

src/humanize/number.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from __future__ import annotations
44

5+
__lazy_modules__ = {"bisect"}
6+
57
import bisect
68

79
from .i18n import _gettext as _

src/humanize/time.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
from __future__ import annotations
77

8+
__lazy_modules__ = {"humanize.i18n", "humanize.number"}
9+
810
from enum import Enum
911
from functools import total_ordering
1012

0 commit comments

Comments
 (0)