From d73b59ea6ab3900c2c31781ba2520b83f7d415c7 Mon Sep 17 00:00:00 2001 From: orip Date: Wed, 25 Nov 2026 12:32:42 +0200 Subject: [PATCH 1/2] Defer Typer imports on Python 3.15 --- tests/test_lazy_imports.py | 28 ++++++++++++++++++++++++++++ typer/__init__.py | 12 ++++++++++++ typer/__main__.py | 4 ++++ typer/_adapters.py | 17 +++++++++++++++++ typer/_click/__init__.py | 8 ++++++++ typer/_click/_compat.py | 13 +++++++++++++ typer/_click/_termui_impl.py | 17 +++++++++++++++++ typer/_click/_textwrap.py | 6 ++++++ typer/_click/_winconsole.py | 12 ++++++++++++ typer/_click/core.py | 18 ++++++++++++++++++ typer/_click/decorators.py | 7 +++++++ typer/_click/exceptions.py | 9 +++++++++ typer/_click/formatting.py | 7 +++++++ typer/_click/globals.py | 5 +++++ typer/_click/parser.py | 7 +++++++ typer/_click/shell_completion.py | 8 ++++++++ typer/_click/termui.py | 11 +++++++++++ typer/_click/utils.py | 12 ++++++++++++ typer/_coercion.py | 15 +++++++++++++++ typer/_completion_classes.py | 11 +++++++++++ typer/_completion_shared.py | 12 ++++++++++++ typer/_display.py | 5 +++++ typer/_param_types.py | 18 ++++++++++++++++++ typer/_typing.py | 7 +++++++ typer/cli.py | 11 +++++++++++ typer/completion.py | 14 ++++++++++++++ typer/core.py | 21 +++++++++++++++++++++ typer/main.py | 24 ++++++++++++++++++++++++ typer/models.py | 9 +++++++++ typer/params.py | 9 +++++++++ typer/rich_utils.py | 27 +++++++++++++++++++++++++++ typer/testing.py | 14 ++++++++++++++ typer/utils.py | 9 +++++++++ 33 files changed, 407 insertions(+) create mode 100644 tests/test_lazy_imports.py diff --git a/tests/test_lazy_imports.py b/tests/test_lazy_imports.py new file mode 100644 index 0000000000..a6fdf20718 --- /dev/null +++ b/tests/test_lazy_imports.py @@ -0,0 +1,28 @@ +import subprocess +import sys +from textwrap import dedent + +import pytest + + +@pytest.mark.skipif(sys.version_info < (3, 15), reason="PEP 810 requires Python 3.15") +def test_public_command_class_is_loaded_on_first_use(): + subprocess.run( + [ + sys.executable, + "-X", + "lazy_imports=normal", + "-c", + dedent( + """\ + import sys + import typer + + assert "typer.main" not in sys.modules + app = typer.Typer() + assert type(app) is sys.modules["typer.main"].Typer + """ + ), + ], + check=True, + ) diff --git a/typer/__init__.py b/typer/__init__.py index c706f83149..9ce396153f 100644 --- a/typer/__init__.py +++ b/typer/__init__.py @@ -1,5 +1,17 @@ """Typer, build great CLIs. Easy to code. Based on Python type hints.""" +__lazy_modules__ = { + "shutil", + "typer", + "typer._click.exceptions", + "typer._click.termui", + "typer._click.utils", + "typer.exceptions", + "typer.main", + "typer.models", + "typer.params", +} + __version__ = "0.29.3" from shutil import get_terminal_size as get_terminal_size diff --git a/typer/__main__.py b/typer/__main__.py index 4e28416e10..ab48ae80de 100644 --- a/typer/__main__.py +++ b/typer/__main__.py @@ -1,3 +1,7 @@ +__lazy_modules__ = { + "typer.cli", +} + from .cli import main main() diff --git a/typer/_adapters.py b/typer/_adapters.py index 448c54afac..ad3268c845 100644 --- a/typer/_adapters.py +++ b/typer/_adapters.py @@ -1,3 +1,20 @@ +__lazy_modules__ = { + "collections.abc", + "contextlib", + "datetime", + "enum", + "os", + "pathlib", + "pydantic", + "pydantic.errors", + "sys", + "typer._click", + "typer._param_types", + "typer._typing", + "typer.models", + "typing", +} + import os import sys from collections.abc import Generator, Sequence diff --git a/typer/_click/__init__.py b/typer/_click/__init__.py index 48c9edcddd..6cec74478c 100644 --- a/typer/_click/__init__.py +++ b/typer/_click/__init__.py @@ -2,6 +2,14 @@ Code taken and adapted from Click: https://github.com/pallets/click/releases/tag/8.3.1 """ +__lazy_modules__ = { + "typer._click.core", + "typer._click.exceptions", + "typer._click.formatting", + "typer._click.termui", + "typer._click.utils", +} + from .core import Command as Command from .core import Context as Context from .core import Parameter as Parameter diff --git a/typer/_click/_compat.py b/typer/_click/_compat.py index 7b4ae5a43d..d1e2723fb5 100644 --- a/typer/_click/_compat.py +++ b/typer/_click/_compat.py @@ -1,3 +1,16 @@ +__lazy_modules__ = { + "codecs", + "collections.abc", + "io", + "os", + "re", + "sys", + "typer._click._winconsole", + "types", + "typing", + "weakref", +} + import codecs import io import os diff --git a/typer/_click/_termui_impl.py b/typer/_click/_termui_impl.py index 20aabd5e97..ebf0a15b10 100644 --- a/typer/_click/_termui_impl.py +++ b/typer/_click/_termui_impl.py @@ -3,6 +3,23 @@ is placed here and only imported as needed. """ +__lazy_modules__ = { + "collections.abc", + "contextlib", + "io", + "math", + "msvcrt", + "os", + "sys", + "termios", + "time", + "tty", + "typer._click._compat", + "typer._click.utils", + "types", + "typing", +} + import contextlib import math import os diff --git a/typer/_click/_textwrap.py b/typer/_click/_textwrap.py index e240956f82..8089b9533f 100644 --- a/typer/_click/_textwrap.py +++ b/typer/_click/_textwrap.py @@ -1,3 +1,9 @@ +__lazy_modules__ = { + "collections.abc", + "contextlib", + "textwrap", +} + import textwrap from collections.abc import Generator from contextlib import contextmanager diff --git a/typer/_click/_winconsole.py b/typer/_click/_winconsole.py index f6dedbfd6e..811e9e915a 100644 --- a/typer/_click/_winconsole.py +++ b/typer/_click/_winconsole.py @@ -6,6 +6,18 @@ # compared to the original patches as we do not need to patch # the entire interpreter but just work in our little world of # echo and prompt. +__lazy_modules__ = { + "collections.abc", + "ctypes", + "ctypes.wintypes", + "io", + "msvcrt", + "sys", + "time", + "typer._click._compat", + "typing", +} + import io import sys import time diff --git a/typer/_click/core.py b/typer/_click/core.py index a405a27660..cc1f6ac7bb 100644 --- a/typer/_click/core.py +++ b/typer/_click/core.py @@ -1,3 +1,21 @@ +__lazy_modules__ = { + "abc", + "collections.abc", + "contextlib", + "enum", + "inspect", + "os", + "typer._click.exceptions", + "typer._click.formatting", + "typer._click.globals", + "typer._click.parser", + "typer._click.termui", + "typer._click.utils", + "typer.exceptions", + "types", + "typing", +} + import enum import inspect import os diff --git a/typer/_click/decorators.py b/typer/_click/decorators.py index 1f5bc43b3f..0bcbfa75d5 100644 --- a/typer/_click/decorators.py +++ b/typer/_click/decorators.py @@ -1,3 +1,10 @@ +__lazy_modules__ = { + "collections.abc", + "typer._click.core", + "typer._click.utils", + "typing", +} + from collections.abc import Callable from typing import TYPE_CHECKING, Any, ParamSpec, TypeVar diff --git a/typer/_click/exceptions.py b/typer/_click/exceptions.py index b546ffa6f4..b6e353c097 100644 --- a/typer/_click/exceptions.py +++ b/typer/_click/exceptions.py @@ -1,3 +1,12 @@ +__lazy_modules__ = { + "collections.abc", + "typer._click._compat", + "typer._click.globals", + "typer._click.utils", + "typer.exceptions", + "typing", +} + from collections.abc import Sequence from typing import IO, TYPE_CHECKING, Any, Union diff --git a/typer/_click/formatting.py b/typer/_click/formatting.py index 28a53741bf..8ca47bbb19 100644 --- a/typer/_click/formatting.py +++ b/typer/_click/formatting.py @@ -1,3 +1,10 @@ +__lazy_modules__ = { + "collections.abc", + "contextlib", + "typer._click._compat", + "typer._click.parser", +} + from collections.abc import Generator, Iterable, Iterator, Sequence from contextlib import contextmanager diff --git a/typer/_click/globals.py b/typer/_click/globals.py index 372dc40749..12ae1e6848 100644 --- a/typer/_click/globals.py +++ b/typer/_click/globals.py @@ -1,3 +1,8 @@ +__lazy_modules__ = { + "threading", + "typing", +} + from threading import local from typing import TYPE_CHECKING, Literal, Union, cast, overload diff --git a/typer/_click/parser.py b/typer/_click/parser.py index 3eb5acd632..d696526082 100644 --- a/typer/_click/parser.py +++ b/typer/_click/parser.py @@ -22,6 +22,13 @@ # maintained by the Python Software Foundation. # Copyright 2001-2006 Gregory P. Ward # Copyright 2002-2006 Python Software Foundation +__lazy_modules__ = { + "collections", + "collections.abc", + "typer._click.exceptions", + "typing", +} + from collections import deque from collections.abc import Sequence from typing import ( diff --git a/typer/_click/shell_completion.py b/typer/_click/shell_completion.py index 29155b7444..80add9bfaa 100644 --- a/typer/_click/shell_completion.py +++ b/typer/_click/shell_completion.py @@ -1,3 +1,11 @@ +__lazy_modules__ = { + "abc", + "collections.abc", + "re", + "typer._click.core", + "typing", +} + import re from abc import ABC, abstractmethod from collections.abc import MutableMapping diff --git a/typer/_click/termui.py b/typer/_click/termui.py index 784ae56212..42fd3715f1 100644 --- a/typer/_click/termui.py +++ b/typer/_click/termui.py @@ -1,3 +1,14 @@ +__lazy_modules__ = { + "collections.abc", + "contextlib", + "io", + "typer._click.exceptions", + "typer._click.globals", + "typer._click.utils", + "typer.exceptions", + "typing", +} + import io from collections.abc import Callable, Iterable from contextlib import AbstractContextManager diff --git a/typer/_click/utils.py b/typer/_click/utils.py index 2d0dc90cb0..78c1187df5 100644 --- a/typer/_click/utils.py +++ b/typer/_click/utils.py @@ -1,3 +1,15 @@ +__lazy_modules__ = { + "collections.abc", + "functools", + "os", + "re", + "sys", + "typer._click._compat", + "typer._click.globals", + "types", + "typing", +} + import os import re import sys diff --git a/typer/_coercion.py b/typer/_coercion.py index 52ded22943..18afa4b244 100644 --- a/typer/_coercion.py +++ b/typer/_coercion.py @@ -1,3 +1,18 @@ +__lazy_modules__ = { + "abc", + "collections.abc", + "dataclasses", + "datetime", + "os", + "typer._click", + "typer._click.exceptions", + "typer._display", + "typer._param_types", + "typer._typing", + "typer.models", + "typing", +} + import os from abc import ABC, abstractmethod from collections.abc import Callable diff --git a/typer/_completion_classes.py b/typer/_completion_classes.py index cfae02c9bf..f949f8903d 100644 --- a/typer/_completion_classes.py +++ b/typer/_completion_classes.py @@ -1,3 +1,14 @@ +__lazy_modules__ = { + "importlib.util", + "os", + "re", + "sys", + "typer", + "typer._click.shell_completion", + "typer._completion_shared", + "typing", +} + import importlib.util import os import re diff --git a/typer/_completion_shared.py b/typer/_completion_shared.py index 96c144c307..766c03c036 100644 --- a/typer/_completion_shared.py +++ b/typer/_completion_shared.py @@ -1,3 +1,15 @@ +__lazy_modules__ = { + "enum", + "os", + "pathlib", + "re", + "shellingham", + "subprocess", + "typer", + "typer._click.globals", + "typer.exceptions", +} + import os import re import subprocess diff --git a/typer/_display.py b/typer/_display.py index d64b2b0006..cfadfc0cf9 100644 --- a/typer/_display.py +++ b/typer/_display.py @@ -1,3 +1,8 @@ +__lazy_modules__ = { + "typer._click.utils", + "typing", +} + from typing import Any from ._click.utils import _escape_control_characters diff --git a/typer/_param_types.py b/typer/_param_types.py index 356e0c7528..217d15a1ad 100644 --- a/typer/_param_types.py +++ b/typer/_param_types.py @@ -1,3 +1,21 @@ +__lazy_modules__ = { + "collections.abc", + "datetime", + "enum", + "os", + "pathlib", + "stat", + "typer._click", + "typer._click._compat", + "typer._click.exceptions", + "typer._click.utils", + "typer._display", + "typer._typing", + "typer.models", + "typing", + "uuid", +} + import os import stat from collections.abc import Sequence diff --git a/typer/_typing.py b/typer/_typing.py index b45965af90..1255d2f9b6 100644 --- a/typer/_typing.py +++ b/typer/_typing.py @@ -1,6 +1,13 @@ # Adapted from pydantic 1.9.2 # mypy: ignore-errors +__lazy_modules__ = { + "collections.abc", + "numbers", + "types", + "typing", +} + import numbers import types from collections.abc import Callable diff --git a/typer/cli.py b/typer/cli.py index 98f9f4ec77..91cc81ce68 100644 --- a/typer/cli.py +++ b/typer/cli.py @@ -1,3 +1,14 @@ +__lazy_modules__ = { + "importlib.util", + "pathlib", + "re", + "sys", + "typer", + "typer._click", + "typer.core", + "typing", +} + import importlib.util import re import sys diff --git a/typer/completion.py b/typer/completion.py index c6b92ad00d..1ae7e23057 100644 --- a/typer/completion.py +++ b/typer/completion.py @@ -1,3 +1,17 @@ +__lazy_modules__ = { + "collections.abc", + "os", + "sys", + "typer", + "typer._click", + "typer._completion_classes", + "typer._completion_shared", + "typer.models", + "typer.params", + "typer.utils", + "typing", +} + import os import sys from collections.abc import MutableMapping diff --git a/typer/core.py b/typer/core.py index 5bdbb2fe75..c73344a93b 100644 --- a/typer/core.py +++ b/typer/core.py @@ -1,3 +1,24 @@ +__lazy_modules__ = { + "collections.abc", + "difflib", + "enum", + "errno", + "gettext", + "inspect", + "os", + "sys", + "typer", + "typer._click.parser", + "typer._click.shell_completion", + "typer._coercion", + "typer._display", + "typer._param_types", + "typer._typing", + "typer.exceptions", + "typer.utils", + "typing", +} + import errno import inspect import os diff --git a/typer/main.py b/typer/main.py index d0be102132..fff1a6acaa 100644 --- a/typer/main.py +++ b/typer/main.py @@ -1,3 +1,27 @@ +__lazy_modules__ = { + "annotated_doc", + "collections.abc", + "functools", + "inspect", + "os", + "platform", + "shutil", + "subprocess", + "sys", + "traceback", + "typer", + "typer._click.globals", + "typer._coercion", + "typer._param_types", + "typer._typing", + "typer.completion", + "typer.core", + "typer.models", + "typer.utils", + "types", + "typing", +} + import inspect import os import platform diff --git a/typer/models.py b/typer/models.py index 2924bca979..a334afc167 100644 --- a/typer/models.py +++ b/typer/models.py @@ -1,3 +1,12 @@ +__lazy_modules__ = { + "collections.abc", + "inspect", + "io", + "typer", + "typer._click.shell_completion", + "typing", +} + import inspect import io from collections.abc import Callable, Sequence diff --git a/typer/params.py b/typer/params.py index ecd8559951..909d6b90a9 100644 --- a/typer/params.py +++ b/typer/params.py @@ -1,3 +1,12 @@ +__lazy_modules__ = { + "annotated_doc", + "collections.abc", + "typer", + "typer._click.shell_completion", + "typer.models", + "typing", +} + from collections.abc import Callable from typing import TYPE_CHECKING, Annotated, Any diff --git a/typer/rich_utils.py b/typer/rich_utils.py index c724035f4b..382e17bec7 100644 --- a/typer/rich_utils.py +++ b/typer/rich_utils.py @@ -1,5 +1,32 @@ # Extracted and modified from https://github.com/ewels/rich-click +__lazy_modules__ = { + "collections", + "collections.abc", + "gettext", + "inspect", + "io", + "os", + "rich", + "rich.align", + "rich.columns", + "rich.console", + "rich.emoji", + "rich.highlighter", + "rich.markdown", + "rich.markup", + "rich.padding", + "rich.panel", + "rich.table", + "rich.text", + "rich.theme", + "rich.traceback", + "typer", + "typer.core", + "typer.models", + "typing", +} + import inspect import io from collections import defaultdict diff --git a/typer/testing.py b/typer/testing.py index b038878dc6..b34ce65a46 100644 --- a/typer/testing.py +++ b/typer/testing.py @@ -1,3 +1,17 @@ +__lazy_modules__ = { + "collections.abc", + "contextlib", + "io", + "os", + "shlex", + "sys", + "typer", + "typer._click", + "typer.main", + "types", + "typing", +} + import contextlib import io import os diff --git a/typer/utils.py b/typer/utils.py index addf9334d4..a6b7b5c366 100644 --- a/typer/utils.py +++ b/typer/utils.py @@ -1,3 +1,12 @@ +__lazy_modules__ = { + "collections.abc", + "copy", + "inspect", + "typer._typing", + "typer.models", + "typing", +} + import inspect from collections.abc import Callable from copy import copy From a78a896278b42d0ca8bc4beb98562208a251f780 Mon Sep 17 00:00:00 2001 From: orip Date: Wed, 25 Nov 2026 22:58:19 +0200 Subject: [PATCH 2/2] Keep imports eager when resolved at module initialization --- typer/__main__.py | 4 ---- typer/_adapters.py | 2 -- typer/_click/_compat.py | 3 --- typer/_click/_termui_impl.py | 3 --- typer/_click/_textwrap.py | 2 -- typer/_click/_winconsole.py | 5 ----- typer/_click/core.py | 5 ----- typer/_click/decorators.py | 3 --- typer/_click/exceptions.py | 2 -- typer/_click/formatting.py | 1 - typer/_click/globals.py | 5 ----- typer/_click/parser.py | 1 - typer/_click/shell_completion.py | 2 -- typer/_click/termui.py | 1 - typer/_click/utils.py | 1 - typer/_coercion.py | 3 --- typer/_completion_classes.py | 2 -- typer/_completion_shared.py | 2 -- typer/_param_types.py | 2 -- typer/_typing.py | 1 - typer/cli.py | 2 -- typer/completion.py | 1 - typer/core.py | 4 ---- typer/main.py | 3 --- typer/models.py | 5 ----- typer/params.py | 1 - typer/rich_utils.py | 5 ----- typer/testing.py | 3 --- 28 files changed, 74 deletions(-) diff --git a/typer/__main__.py b/typer/__main__.py index ab48ae80de..4e28416e10 100644 --- a/typer/__main__.py +++ b/typer/__main__.py @@ -1,7 +1,3 @@ -__lazy_modules__ = { - "typer.cli", -} - from .cli import main main() diff --git a/typer/_adapters.py b/typer/_adapters.py index ad3268c845..9dbd80c494 100644 --- a/typer/_adapters.py +++ b/typer/_adapters.py @@ -1,6 +1,5 @@ __lazy_modules__ = { "collections.abc", - "contextlib", "datetime", "enum", "os", @@ -12,7 +11,6 @@ "typer._param_types", "typer._typing", "typer.models", - "typing", } import os diff --git a/typer/_click/_compat.py b/typer/_click/_compat.py index d1e2723fb5..ef1564706f 100644 --- a/typer/_click/_compat.py +++ b/typer/_click/_compat.py @@ -1,10 +1,7 @@ __lazy_modules__ = { "codecs", "collections.abc", - "io", "os", - "re", - "sys", "typer._click._winconsole", "types", "typing", diff --git a/typer/_click/_termui_impl.py b/typer/_click/_termui_impl.py index ebf0a15b10..a9fb2cc8d7 100644 --- a/typer/_click/_termui_impl.py +++ b/typer/_click/_termui_impl.py @@ -9,15 +9,12 @@ "io", "math", "msvcrt", - "os", - "sys", "termios", "time", "tty", "typer._click._compat", "typer._click.utils", "types", - "typing", } import contextlib diff --git a/typer/_click/_textwrap.py b/typer/_click/_textwrap.py index 8089b9533f..b035084be0 100644 --- a/typer/_click/_textwrap.py +++ b/typer/_click/_textwrap.py @@ -1,7 +1,5 @@ __lazy_modules__ = { "collections.abc", - "contextlib", - "textwrap", } import textwrap diff --git a/typer/_click/_winconsole.py b/typer/_click/_winconsole.py index 811e9e915a..44f2418e18 100644 --- a/typer/_click/_winconsole.py +++ b/typer/_click/_winconsole.py @@ -8,14 +8,9 @@ # echo and prompt. __lazy_modules__ = { "collections.abc", - "ctypes", - "ctypes.wintypes", - "io", "msvcrt", - "sys", "time", "typer._click._compat", - "typing", } import io diff --git a/typer/_click/core.py b/typer/_click/core.py index cc1f6ac7bb..910300bcb6 100644 --- a/typer/_click/core.py +++ b/typer/_click/core.py @@ -1,19 +1,14 @@ __lazy_modules__ = { - "abc", "collections.abc", - "contextlib", - "enum", "inspect", "os", "typer._click.exceptions", - "typer._click.formatting", "typer._click.globals", "typer._click.parser", "typer._click.termui", "typer._click.utils", "typer.exceptions", "types", - "typing", } import enum diff --git a/typer/_click/decorators.py b/typer/_click/decorators.py index 0bcbfa75d5..37e1250b73 100644 --- a/typer/_click/decorators.py +++ b/typer/_click/decorators.py @@ -1,8 +1,5 @@ __lazy_modules__ = { - "collections.abc", - "typer._click.core", "typer._click.utils", - "typing", } from collections.abc import Callable diff --git a/typer/_click/exceptions.py b/typer/_click/exceptions.py index b6e353c097..72ceba0aa7 100644 --- a/typer/_click/exceptions.py +++ b/typer/_click/exceptions.py @@ -3,8 +3,6 @@ "typer._click._compat", "typer._click.globals", "typer._click.utils", - "typer.exceptions", - "typing", } from collections.abc import Sequence diff --git a/typer/_click/formatting.py b/typer/_click/formatting.py index 8ca47bbb19..397591dd04 100644 --- a/typer/_click/formatting.py +++ b/typer/_click/formatting.py @@ -1,6 +1,5 @@ __lazy_modules__ = { "collections.abc", - "contextlib", "typer._click._compat", "typer._click.parser", } diff --git a/typer/_click/globals.py b/typer/_click/globals.py index 12ae1e6848..372dc40749 100644 --- a/typer/_click/globals.py +++ b/typer/_click/globals.py @@ -1,8 +1,3 @@ -__lazy_modules__ = { - "threading", - "typing", -} - from threading import local from typing import TYPE_CHECKING, Literal, Union, cast, overload diff --git a/typer/_click/parser.py b/typer/_click/parser.py index d696526082..468178ae20 100644 --- a/typer/_click/parser.py +++ b/typer/_click/parser.py @@ -26,7 +26,6 @@ "collections", "collections.abc", "typer._click.exceptions", - "typing", } from collections import deque diff --git a/typer/_click/shell_completion.py b/typer/_click/shell_completion.py index 80add9bfaa..ee55de47d0 100644 --- a/typer/_click/shell_completion.py +++ b/typer/_click/shell_completion.py @@ -1,9 +1,7 @@ __lazy_modules__ = { - "abc", "collections.abc", "re", "typer._click.core", - "typing", } import re diff --git a/typer/_click/termui.py b/typer/_click/termui.py index 42fd3715f1..8511a16ce5 100644 --- a/typer/_click/termui.py +++ b/typer/_click/termui.py @@ -6,7 +6,6 @@ "typer._click.globals", "typer._click.utils", "typer.exceptions", - "typing", } import io diff --git a/typer/_click/utils.py b/typer/_click/utils.py index 78c1187df5..8d7ed4687d 100644 --- a/typer/_click/utils.py +++ b/typer/_click/utils.py @@ -7,7 +7,6 @@ "typer._click._compat", "typer._click.globals", "types", - "typing", } import os diff --git a/typer/_coercion.py b/typer/_coercion.py index 18afa4b244..1a32cef949 100644 --- a/typer/_coercion.py +++ b/typer/_coercion.py @@ -1,7 +1,5 @@ __lazy_modules__ = { - "abc", "collections.abc", - "dataclasses", "datetime", "os", "typer._click", @@ -10,7 +8,6 @@ "typer._param_types", "typer._typing", "typer.models", - "typing", } import os diff --git a/typer/_completion_classes.py b/typer/_completion_classes.py index f949f8903d..df025563ec 100644 --- a/typer/_completion_classes.py +++ b/typer/_completion_classes.py @@ -4,8 +4,6 @@ "re", "sys", "typer", - "typer._click.shell_completion", - "typer._completion_shared", "typing", } diff --git a/typer/_completion_shared.py b/typer/_completion_shared.py index 766c03c036..43d8e6d9f5 100644 --- a/typer/_completion_shared.py +++ b/typer/_completion_shared.py @@ -1,8 +1,6 @@ __lazy_modules__ = { - "enum", "os", "pathlib", - "re", "shellingham", "subprocess", "typer", diff --git a/typer/_param_types.py b/typer/_param_types.py index 217d15a1ad..a5e212f464 100644 --- a/typer/_param_types.py +++ b/typer/_param_types.py @@ -11,8 +11,6 @@ "typer._click.utils", "typer._display", "typer._typing", - "typer.models", - "typing", "uuid", } diff --git a/typer/_typing.py b/typer/_typing.py index 1255d2f9b6..0a8c00546e 100644 --- a/typer/_typing.py +++ b/typer/_typing.py @@ -5,7 +5,6 @@ "collections.abc", "numbers", "types", - "typing", } import numbers diff --git a/typer/cli.py b/typer/cli.py index 91cc81ce68..b98131c493 100644 --- a/typer/cli.py +++ b/typer/cli.py @@ -3,9 +3,7 @@ "pathlib", "re", "sys", - "typer", "typer._click", - "typer.core", "typing", } diff --git a/typer/completion.py b/typer/completion.py index 1ae7e23057..9eb21dfbeb 100644 --- a/typer/completion.py +++ b/typer/completion.py @@ -7,7 +7,6 @@ "typer._completion_classes", "typer._completion_shared", "typer.models", - "typer.params", "typer.utils", "typing", } diff --git a/typer/core.py b/typer/core.py index c73344a93b..270f23a0c5 100644 --- a/typer/core.py +++ b/typer/core.py @@ -5,17 +5,13 @@ "errno", "gettext", "inspect", - "os", "sys", - "typer", "typer._click.parser", "typer._click.shell_completion", "typer._coercion", "typer._display", "typer._param_types", - "typer._typing", "typer.exceptions", - "typer.utils", "typing", } diff --git a/typer/main.py b/typer/main.py index fff1a6acaa..852fd097e8 100644 --- a/typer/main.py +++ b/typer/main.py @@ -7,7 +7,6 @@ "platform", "shutil", "subprocess", - "sys", "traceback", "typer", "typer._click.globals", @@ -15,8 +14,6 @@ "typer._param_types", "typer._typing", "typer.completion", - "typer.core", - "typer.models", "typer.utils", "types", "typing", diff --git a/typer/models.py b/typer/models.py index a334afc167..aded589800 100644 --- a/typer/models.py +++ b/typer/models.py @@ -1,10 +1,5 @@ __lazy_modules__ = { - "collections.abc", - "inspect", - "io", - "typer", "typer._click.shell_completion", - "typing", } import inspect diff --git a/typer/params.py b/typer/params.py index 909d6b90a9..e6b6089965 100644 --- a/typer/params.py +++ b/typer/params.py @@ -4,7 +4,6 @@ "typer", "typer._click.shell_completion", "typer.models", - "typing", } from collections.abc import Callable diff --git a/typer/rich_utils.py b/typer/rich_utils.py index 382e17bec7..67314e24db 100644 --- a/typer/rich_utils.py +++ b/typer/rich_utils.py @@ -3,16 +3,12 @@ __lazy_modules__ = { "collections", "collections.abc", - "gettext", "inspect", "io", - "os", "rich", "rich.align", "rich.columns", - "rich.console", "rich.emoji", - "rich.highlighter", "rich.markdown", "rich.markup", "rich.padding", @@ -24,7 +20,6 @@ "typer", "typer.core", "typer.models", - "typing", } import inspect diff --git a/typer/testing.py b/typer/testing.py index b34ce65a46..b35cfa124f 100644 --- a/typer/testing.py +++ b/typer/testing.py @@ -1,7 +1,5 @@ __lazy_modules__ = { "collections.abc", - "contextlib", - "io", "os", "shlex", "sys", @@ -9,7 +7,6 @@ "typer._click", "typer.main", "types", - "typing", } import contextlib