__init__.py
This file
Path
src/click/__init__.py
122 lines · 4.4 KiB · Python
Last changed by
deprecate `__version__` attribute (#2599)David Lordbefore adoptionb63ace2
History of this fileTake it
1"""2Click is a simple Python module inspired by the stdlib optparse to make3writing command line scripts fun. Unlike other modules, it's based4around a simple API that does not come with too much magic and is5composable.6"""7from __future__ import annotations89from .core import Argument as Argument10from .core import Command as Command11from .core import CommandCollection as CommandCollection12from .core import Context as Context13from .core import Group as Group14from .core import Option as Option15from .core import Parameter as Parameter16from .decorators import argument as argument17from .decorators import command as command18from .decorators import confirmation_option as confirmation_option19from .decorators import group as group20from .decorators import help_option as help_option21from .decorators import make_pass_decorator as make_pass_decorator22from .decorators import option as option23from .decorators import pass_context as pass_context24from .decorators import pass_obj as pass_obj25from .decorators import password_option as password_option26from .decorators import version_option as version_option27from .exceptions import Abort as Abort28from .exceptions import BadArgumentUsage as BadArgumentUsage29from .exceptions import BadOptionUsage as BadOptionUsage30from .exceptions import BadParameter as BadParameter31from .exceptions import ClickException as ClickException32from .exceptions import FileError as FileError33from .exceptions import MissingParameter as MissingParameter34from .exceptions import NoSuchOption as NoSuchOption35from .exceptions import UsageError as UsageError36from .formatting import HelpFormatter as HelpFormatter37from .formatting import wrap_text as wrap_text38from .globals import get_current_context as get_current_context39from .termui import clear as clear40from .termui import confirm as confirm41from .termui import echo_via_pager as echo_via_pager42from .termui import edit as edit43from .termui import getchar as getchar44from .termui import launch as launch45from .termui import pause as pause46from .termui import progressbar as progressbar47from .termui import prompt as prompt48from .termui import secho as secho49from .termui import style as style50from .termui import unstyle as unstyle51from .types import BOOL as BOOL52from .types import Choice as Choice53from .types import DateTime as DateTime54from .types import File as File55from .types import FLOAT as FLOAT56from .types import FloatRange as FloatRange57from .types import INT as INT58from .types import IntRange as IntRange59from .types import ParamType as ParamType60from .types import Path as Path61from .types import STRING as STRING62from .types import Tuple as Tuple63from .types import UNPROCESSED as UNPROCESSED64from .types import UUID as UUID65from .utils import echo as echo66from .utils import format_filename as format_filename67from .utils import get_app_dir as get_app_dir68from .utils import get_binary_stream as get_binary_stream69from .utils import get_text_stream as get_text_stream70from .utils import open_file as open_file717273def __getattr__(name: str) -> object:74 import warnings7576 if name == "BaseCommand":77 from .core import _BaseCommand7879 warnings.warn(80 "'BaseCommand' is deprecated and will be removed in Click 9.0. Use"81 " 'Command' instead.",82 DeprecationWarning,83 stacklevel=2,84 )85 return _BaseCommand8687 if name == "MultiCommand":88 from .core import _MultiCommand8990 warnings.warn(91 "'MultiCommand' is deprecated and will be removed in Click 9.0. Use"92 " 'Group' instead.",93 DeprecationWarning,94 stacklevel=2,95 )96 return _MultiCommand9798 if name == "OptionParser":99 from .parser import _OptionParser100101 warnings.warn(102 "'OptionParser' is deprecated and will be removed in Click 9.0. The"103 " old parser is available in 'optparse'.",104 DeprecationWarning,105 stacklevel=2,106 )107 return _OptionParser108109 if name == "__version__":110 import importlib.metadata111 import warnings112113 warnings.warn(114 "The '__version__' attribute is deprecated and will be removed in"115 " Click 9.1. Use feature detection or"116 " 'importlib.metadata.version(\"click\")' instead.",117 DeprecationWarning,118 stacklevel=2,119 )120 return importlib.metadata.version("click")121122 raise AttributeError(name)