Complete stubs for click-web (#13806)

This commit is contained in:
Semyon Moroz
2025-04-11 16:54:34 +04:00
committed by GitHub
parent bb1cbfab59
commit e3002c6f0d
5 changed files with 75 additions and 26 deletions
@@ -1,4 +1,6 @@
import logging
from collections.abc import Generator
from typing import ClassVar, Final
from flask import Response
@@ -6,19 +8,20 @@ from .input_fields import FieldId
logger: logging.Logger | None
HTML_HEAD: str
HTML_TAIL: str
HTML_HEAD: Final[str]
HTML_TAIL: Final[str]
class Executor:
RAW_CMD_PATH: str
RAW_CMD_PATH: ClassVar[str]
returncode: int | None
def __init__(self) -> None: ...
def exec(self, command_path: str) -> Response: ...
def _exec_raw(self, command: list[str]) -> Response: ... # undocumented
def _exec_html(self, command_path: str) -> Response: ... # undocumented
def _run_script_and_generate_stream(self) -> None: ... # undocumented
def _run_script_and_generate_stream(self) -> Generator[str]: ... # undocumented
def _create_cmd_header(self, commands: list[CmdPart]) -> str: ... # undocumented
def _create_result_footer(self) -> str: ... # undocumented
def _create_result_footer(self) -> Generator[str]: ... # undocumented
def _get_download_link(field_info: FieldFileInfo) -> str: ... # undocumented
@@ -30,6 +33,7 @@ class CommandLineRaw:
def after_script_executed(self) -> None: ...
class CommandLineForm:
command_line_bulder: FormToCommandLineBuilder
def __init__(self, script_file_path: str, commands: list[str]) -> None: ...
def append(self, part: str, secret: bool = False) -> None: ...
def get_commandline(self, obfuscate: bool = False) -> list[str]: ...
@@ -49,6 +53,11 @@ class FormToCommandLineBuilder:
def _process_option(self, field_info: FieldInfo) -> None: ...
class FieldInfo:
param: FieldId
key: str
is_file: bool
cmd_opt: str
generate_download_link: bool
@staticmethod
def factory(key: str) -> FieldInfo: ...
def __init__(self, param: FieldId) -> None: ...
@@ -58,6 +67,10 @@ class FieldInfo:
def __eq__(self, other: object) -> bool: ...
class FieldFileInfo(FieldInfo):
mode: str
generate_download_link: bool
link_name: str
file_path: str
def __init__(self, fimeta: FieldId) -> None: ...
def before_script_execute(self) -> None: ...
@classmethod
@@ -65,6 +78,7 @@ class FieldFileInfo(FieldInfo):
def save(self) -> None: ...
class FieldOutFileInfo(FieldFileInfo):
file_suffix: str
def __init__(self, fimeta: FieldId) -> None: ...
def save(self) -> None: ...
@@ -1,6 +1,9 @@
from collections import OrderedDict
from typing import Any
import click
def index() -> str: ...
def _click_to_tree(ctx: click.Context, node: click.Command, ancestors: list[click.Command] | None = None) -> dict[str, Any]: ...
def _click_to_tree(
ctx: click.Context, node: click.Command, ancestors: list[click.Command] | None = None
) -> OrderedDict[str, Any]: ...
@@ -1,9 +1,18 @@
from typing import Any
from typing import Any, ClassVar, Final
import click
from click_web.web_click_types import EmailParamType, PasswordParamType, TextAreaParamType
class FieldId:
SEPARATOR: str
SEPARATOR: ClassVar[str]
command_index: int
param_index: int
param_type: str
click_type: str
nargs: int
form_type: str
name: str
key: str
def __init__(
self,
@@ -22,7 +31,11 @@ class FieldId:
class NotSupported(ValueError): ...
class BaseInput:
param_type_cls: type | None
param_type_cls: type[click.types.ParamType] | None
ctx: click.Context
param: click.Parameter
command_index: int
param_index: int
def __init__(self, ctx: click.Context, param: click.Parameter, command_index: int, param_index: int) -> None: ...
def is_supported(self) -> bool: ...
@property
@@ -32,18 +45,37 @@ class BaseInput:
def _to_cmd_line_name(self, name: str) -> str: ...
def _build_name(self, name: str): ...
class ChoiceInput(BaseInput): ...
class FlagInput(BaseInput): ...
class IntInput(BaseInput): ...
class FloatInput(BaseInput): ...
class FolderInput(BaseInput): ...
class FileInput(BaseInput): ...
class EmailInput(BaseInput): ...
class PasswordInput(BaseInput): ...
class TextAreaInput(BaseInput): ...
class DefaultInput(BaseInput): ...
class ChoiceInput(BaseInput):
param_type_cls: type[click.Choice]
INPUT_TYPES: list[type]
_DEFAULT_INPUT: list[type]
class FlagInput(BaseInput):
param_type_cls: None
class IntInput(BaseInput):
param_type_cls: type[click.types.IntParamType]
class FloatInput(BaseInput):
param_type_cls: type[click.types.FloatParamType]
class FolderInput(BaseInput):
param_type_cls: None
class FileInput(BaseInput):
param_type_cls: None
class EmailInput(BaseInput):
param_type_cls: type[EmailParamType]
class PasswordInput(BaseInput):
param_type_cls: type[PasswordParamType]
class TextAreaInput(BaseInput):
param_type_cls: type[TextAreaParamType]
class DefaultInput(BaseInput):
param_type_cls: type[click.ParamType]
INPUT_TYPES: Final[list[type[BaseInput]]]
_DEFAULT_INPUT: Final[list[type[DefaultInput]]]
def get_input_field(ctx: click.Context, param: click.Parameter, command_index, param_index) -> dict[str, Any]: ...
@@ -1,17 +1,17 @@
import re
import typing as t
from typing import ClassVar
import click
class EmailParamType(click.ParamType):
EMAIL_REGEX: re.Pattern[str]
def convert(self, value: t.Any, param: click.Parameter | None, ctx: click.Context | None) -> t.Any: ...
EMAIL_REGEX: ClassVar[re.Pattern[str]]
def convert(self, value: str, param: click.Parameter | None, ctx: click.Context | None) -> str | None: ...
class PasswordParamType(click.ParamType):
def convert(self, value: t.Any, param: click.Parameter | None, ctx: click.Context | None) -> t.Any: ...
def convert(self, value: str, param: click.Parameter | None, ctx: click.Context | None) -> str | None: ...
class TextAreaParamType(click.ParamType):
def convert(self, value: t.Any, param: click.Parameter | None, ctx: click.Context | None) -> t.Any: ...
def convert(self, value: str, param: click.Parameter | None, ctx: click.Context | None) -> str | None: ...
EMAIL_TYPE: EmailParamType
PASSWORD_TYPE: PasswordParamType