Skip to content

Commit 75c42e4

Browse files
committed
Add stubs for "click-web" package
1 parent 98f070a commit 75c42e4

File tree

9 files changed

+179
-0
lines changed

9 files changed

+179
-0
lines changed

Diff for: pyrightconfig.stricter.json

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"stubs/caldav",
3939
"stubs/cffi",
4040
"stubs/click-default-group",
41+
"stubs/click-web",
4142
"stubs/commonmark",
4243
"stubs/corus",
4344
"stubs/dateparser",

Diff for: stubs/click-web/METADATA.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version = "0.8.*"
2+
requires = ["click>=8.0.0", "Flask>=2.3.2", "Jinja2>=3.1.3"]
3+
upstream_repository = "https://github.com/fredrik-corneliusson/click-web"

Diff for: stubs/click-web/click_web/__init__.pyi

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import logging
2+
import types
3+
4+
import click
5+
import flask
6+
import jinja2
7+
8+
jinja_env: jinja2.Environment
9+
script_file: str | None
10+
click_root_cmd: str | None
11+
OUTPUT_FOLDER: str
12+
_flask_app: flask.Flask | None
13+
logger: logging.Logger | None
14+
15+
def create_click_web_app(module: types.ModuleType, command: click.BaseCommand, root: str = "/") -> flask.Flask: ...

Diff for: stubs/click-web/click_web/exceptions.pyi

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class ClickWebException(Exception): ...
2+
class CommandNotFound(ClickWebException): ...

Diff for: stubs/click-web/click_web/resources/cmd_exec.pyi

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import logging
2+
3+
from flask import Response
4+
5+
from .input_fields import FieldId
6+
7+
logger: logging.Logger | None
8+
9+
HTML_HEAD: str
10+
HTML_TAIL: str
11+
12+
class Executor:
13+
RAW_CMD_PATH: str
14+
15+
def __init__(self) -> None: ...
16+
def exec(self, command_path: str) -> Response: ...
17+
def _exec_raw(self, command: list[str]) -> Response: ... # undocumented
18+
def _exec_html(self, command_path: str) -> Response: ... # undocumented
19+
def _run_script_and_generate_stream(self) -> None: ... # undocumented
20+
def _create_cmd_header(self, commands: list[CmdPart]) -> str: ... # undocumented
21+
def _create_result_footer(self) -> str: ... # undocumented
22+
23+
def _get_download_link(field_info: FieldFileInfo) -> str: ... # undocumented
24+
25+
class CommandLineRaw:
26+
def __init__(self, script_file_path: str, command: str) -> None: ...
27+
def append(self, part: str, secret: bool = False) -> None: ...
28+
def get_commandline(self, obfuscate: bool = False) -> list[str]: ...
29+
def get_download_field_infos(self) -> list[FieldInfo]: ...
30+
def after_script_executed(self) -> None: ...
31+
32+
class CommandLineForm:
33+
def __init__(self, script_file_path: str, commands: list[str]) -> None: ...
34+
def append(self, part: str, secret: bool = False) -> None: ...
35+
def get_commandline(self, obfuscate: bool = False) -> list[str]: ...
36+
def get_download_field_infos(self) -> list[FieldInfo]: ...
37+
def after_script_executed(self) -> None: ...
38+
39+
def _get_python_interpreter() -> str: ...
40+
41+
class CmdPart:
42+
def __init__(self, part: str, secret: bool = False) -> None: ...
43+
44+
class FormToCommandLineBuilder:
45+
def __init__(self, command_line: CommandLineForm) -> None: ...
46+
def add_command_args(self, command_index: int) -> None: ...
47+
@staticmethod
48+
def _is_option(cmd_option: str) -> bool: ...
49+
def _process_option(self, field_info: FieldInfo) -> None: ...
50+
51+
class FieldInfo:
52+
@staticmethod
53+
def factory(key: str) -> FieldInfo: ...
54+
def __init__(self, param: FieldId) -> None: ...
55+
def before_script_execute(self) -> None: ...
56+
def after_script_executed(self) -> None: ...
57+
def __lt__(self, other: object) -> bool: ...
58+
def __eq__(self, other: object) -> bool: ...
59+
60+
class FieldFileInfo(FieldInfo):
61+
def __init__(self, fimeta: FieldId) -> None: ...
62+
def before_script_execute(self) -> None: ...
63+
@classmethod
64+
def temp_dir(cls) -> str: ...
65+
def save(self) -> None: ...
66+
67+
class FieldOutFileInfo(FieldFileInfo):
68+
def __init__(self, fimeta: FieldId) -> None: ...
69+
def save(self) -> None: ...
70+
71+
class FieldPathInfo(FieldFileInfo):
72+
def save(self) -> None: ...
73+
def after_script_executed(self) -> None: ...
74+
75+
class FieldPathOutInfo(FieldOutFileInfo):
76+
def save(self) -> None: ...
77+
def after_script_executed(self) -> None: ...
78+
79+
def zip_folder(folder_path: str, out_folder: str, out_prefix: str) -> str: ...

Diff for: stubs/click-web/click_web/resources/cmd_form.pyi

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import click
2+
3+
def get_form_for(command_path: str) -> str: ...
4+
def _get_commands_by_path(command_path: str) -> list[tuple[click.Context, click.Command]]: ...
5+
def _generate_form_data(ctx_and_commands: list[tuple[click.Context, click.Command]]): ...
6+
def _process_help(help_text: bool) -> str: ...

Diff for: stubs/click-web/click_web/resources/index.pyi

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from typing import Any
2+
3+
import click
4+
5+
def index() -> str: ...
6+
def _click_to_tree(ctx: click.Context, node: click.Command, ancestors: list[click.Command] | None = None) -> dict[str, Any]: ...

Diff for: stubs/click-web/click_web/resources/input_fields.pyi

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
from typing import Any
2+
3+
import click
4+
5+
class FieldId:
6+
SEPARATOR: str
7+
8+
def __init__(
9+
self,
10+
command_index: int,
11+
param_index: int,
12+
param_type: str,
13+
click_type: str,
14+
nargs: int,
15+
form_type: str,
16+
name: str,
17+
key: str | None = None,
18+
): ...
19+
@classmethod
20+
def from_string(cls, field_info_as_string: str) -> FieldId: ...
21+
22+
class NotSupported(ValueError): ...
23+
24+
class BaseInput:
25+
param_type_cls: type | None
26+
def __init__(self, ctx: click.Context, param: click.Parameter, command_index: int, param_index: int) -> None: ...
27+
def is_supported(self) -> bool: ...
28+
@property
29+
def fields(self) -> dict[str, Any]: ...
30+
@property
31+
def type_attrs(self) -> dict[str, Any]: ...
32+
def _to_cmd_line_name(self, name: str) -> str: ...
33+
def _build_name(self, name: str): ...
34+
35+
class ChoiceInput(BaseInput): ...
36+
class FlagInput(BaseInput): ...
37+
class IntInput(BaseInput): ...
38+
class FloatInput(BaseInput): ...
39+
class FolderInput(BaseInput): ...
40+
class FileInput(BaseInput): ...
41+
class EmailInput(BaseInput): ...
42+
class PasswordInput(BaseInput): ...
43+
class TextAreaInput(BaseInput): ...
44+
class DefaultInput(BaseInput): ...
45+
46+
INPUT_TYPES: list[type]
47+
_DEFAULT_INPUT: list[type]
48+
49+
def get_input_field(ctx: click.Context, param: click.Parameter, command_index, param_index) -> dict[str, Any]: ...

Diff for: stubs/click-web/click_web/web_click_types.pyi

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import re
2+
import typing as t
3+
4+
import click
5+
6+
class EmailParamType(click.ParamType):
7+
EMAIL_REGEX: re.Pattern[str]
8+
def convert(self, value: t.Any, param: click.Parameter | None, ctx: click.Context | None) -> t.Any: ...
9+
10+
class PasswordParamType(click.ParamType):
11+
def convert(self, value: t.Any, param: click.Parameter | None, ctx: click.Context | None) -> t.Any: ...
12+
13+
class TextAreaParamType(click.ParamType):
14+
def convert(self, value: t.Any, param: click.Parameter | None, ctx: click.Context | None) -> t.Any: ...
15+
16+
EMAIL_TYPE: EmailParamType
17+
PASSWORD_TYPE: PasswordParamType
18+
TEXTAREA_TYPE: TextAreaParamType

0 commit comments

Comments
 (0)