diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index e806a5f40..715ec3347 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -38,6 +38,7 @@ "stubs/Flask", "stubs/html5lib", "stubs/httplib2", + "stubs/humanfriendly", "stubs/Jinja2", "stubs/jmespath", "stubs/jsonschema", diff --git a/stubs/humanfriendly/@tests/requirements-stubtest.txt b/stubs/humanfriendly/@tests/requirements-stubtest.txt new file mode 100644 index 000000000..2d34645ab --- /dev/null +++ b/stubs/humanfriendly/@tests/requirements-stubtest.txt @@ -0,0 +1,2 @@ +docutils +mock \ No newline at end of file diff --git a/stubs/humanfriendly/@tests/stubtest_allowlist.txt b/stubs/humanfriendly/@tests/stubtest_allowlist.txt new file mode 100644 index 000000000..deebbcb2c --- /dev/null +++ b/stubs/humanfriendly/@tests/stubtest_allowlist.txt @@ -0,0 +1,2 @@ +humanfriendly.compat.StringIO.seek +humanfriendly.compat.StringIO.truncate diff --git a/stubs/humanfriendly/METADATA.toml b/stubs/humanfriendly/METADATA.toml new file mode 100644 index 000000000..27a0042d1 --- /dev/null +++ b/stubs/humanfriendly/METADATA.toml @@ -0,0 +1 @@ +version = "9.2" diff --git a/stubs/humanfriendly/humanfriendly/__init__.pyi b/stubs/humanfriendly/humanfriendly/__init__.pyi new file mode 100644 index 000000000..1e6877718 --- /dev/null +++ b/stubs/humanfriendly/humanfriendly/__init__.pyi @@ -0,0 +1,48 @@ +from typing import Any, NamedTuple + +class SizeUnit(NamedTuple): + divider: Any + symbol: Any + name: Any + +class CombinedUnit(NamedTuple): + decimal: Any + binary: Any + +disk_size_units: Any +length_size_units: Any +time_units: Any + +def coerce_boolean(value): ... +def coerce_pattern(value, flags: int = ...): ... +def coerce_seconds(value): ... +def format_size(num_bytes, keep_width: bool = ..., binary: bool = ...): ... +def parse_size(size, binary: bool = ...): ... +def format_length(num_metres, keep_width: bool = ...): ... +def parse_length(length): ... +def format_number(number, num_decimals: int = ...): ... +def round_number(count, keep_width: bool = ...): ... +def format_timespan(num_seconds, detailed: bool = ..., max_units: int = ...): ... +def parse_timespan(timespan): ... +def parse_date(datestring): ... +def format_path(pathname): ... +def parse_path(pathname): ... + +class Timer: + monotonic: bool + resumable: bool + start_time: float + total_time: float + def __init__(self, start_time: Any | None = ..., resumable: bool = ...) -> None: ... + def __enter__(self): ... + def __exit__(self, exc_type: Any | None = ..., exc_value: Any | None = ..., traceback: Any | None = ...) -> None: ... + def sleep(self, seconds) -> None: ... + @property + def elapsed_time(self): ... + @property + def rounded(self): ... + +class InvalidDate(Exception): ... +class InvalidSize(Exception): ... +class InvalidLength(Exception): ... +class InvalidTimespan(Exception): ... diff --git a/stubs/humanfriendly/humanfriendly/case.pyi b/stubs/humanfriendly/humanfriendly/case.pyi new file mode 100644 index 000000000..b3e276725 --- /dev/null +++ b/stubs/humanfriendly/humanfriendly/case.pyi @@ -0,0 +1,23 @@ +import collections +from typing import Any + +from humanfriendly.compat import unicode + +class CaseInsensitiveDict(collections.OrderedDict): + def __init__(self, other: Any | None = ..., **kw) -> None: ... + def coerce_key(self, key): ... + @classmethod + def fromkeys(cls, iterable, value: Any | None = ...): ... + def get(self, key, default: Any | None = ...): ... + def pop(self, key, default: Any | None = ...): ... + def setdefault(self, key, default: Any | None = ...): ... + def update(self, other: Any | None = ..., **kw) -> None: ... # type: ignore + def __contains__(self, key): ... + def __delitem__(self, key): ... + def __getitem__(self, key): ... + def __setitem__(self, key, value): ... + +class CaseInsensitiveKey(unicode): + def __new__(cls, value): ... + def __hash__(self): ... + def __eq__(self, other): ... diff --git a/stubs/humanfriendly/humanfriendly/cli.pyi b/stubs/humanfriendly/humanfriendly/cli.pyi new file mode 100644 index 000000000..200009fc3 --- /dev/null +++ b/stubs/humanfriendly/humanfriendly/cli.pyi @@ -0,0 +1,13 @@ +from typing import Any + +def main() -> None: ... +def run_command(command_line) -> None: ... +def print_formatted_length(value) -> None: ... +def print_formatted_number(value) -> None: ... +def print_formatted_size(value, binary) -> None: ... +def print_formatted_table(delimiter) -> None: ... +def print_formatted_timespan(value) -> None: ... +def print_parsed_length(value) -> None: ... +def print_parsed_size(value) -> None: ... +def demonstrate_ansi_formatting() -> None: ... +def demonstrate_256_colors(i, j, group: Any | None = ...) -> None: ... diff --git a/stubs/humanfriendly/humanfriendly/compat.pyi b/stubs/humanfriendly/humanfriendly/compat.pyi new file mode 100644 index 000000000..431dc3447 --- /dev/null +++ b/stubs/humanfriendly/humanfriendly/compat.pyi @@ -0,0 +1,23 @@ +import sys + +if sys.version_info >= (3, 0): + unicode = str + unichr = chr + basestring = str + interactive_prompt = input + from html.parser import HTMLParser as HTMLParser + from io import StringIO as StringIO +else: + unicode = unicode + unichr = unichr + basestring = basestring + interactive_prompt = raw_input + from StringIO import StringIO as StringIO + + from HTMLParser import HTMLParser as HTMLParser + +def coerce_string(value): ... +def is_string(value): ... +def is_unicode(value): ... +def on_macos(): ... +def on_windows(): ... diff --git a/stubs/humanfriendly/humanfriendly/decorators.pyi b/stubs/humanfriendly/humanfriendly/decorators.pyi new file mode 100644 index 000000000..e961fd398 --- /dev/null +++ b/stubs/humanfriendly/humanfriendly/decorators.pyi @@ -0,0 +1,3 @@ +RESULTS_ATTRIBUTE: str + +def cached(function): ... diff --git a/stubs/humanfriendly/humanfriendly/deprecation.pyi b/stubs/humanfriendly/humanfriendly/deprecation.pyi new file mode 100644 index 000000000..f384fa8aa --- /dev/null +++ b/stubs/humanfriendly/humanfriendly/deprecation.pyi @@ -0,0 +1,14 @@ +import types +from typing import Any + +def define_aliases(module_name, **aliases) -> None: ... +def get_aliases(module_name): ... +def deprecated_args(*names): ... +def is_method(function): ... + +class DeprecationProxy(types.ModuleType): + module: Any + aliases: Any + def __init__(self, module, aliases) -> None: ... + def __getattr__(self, name): ... + def resolve(self, target): ... diff --git a/stubs/humanfriendly/humanfriendly/prompts.pyi b/stubs/humanfriendly/humanfriendly/prompts.pyi new file mode 100644 index 000000000..9bc7a4fb4 --- /dev/null +++ b/stubs/humanfriendly/humanfriendly/prompts.pyi @@ -0,0 +1,13 @@ +from typing import Any + +MAX_ATTEMPTS: int +logger: Any + +def prompt_for_confirmation(question, default: Any | None = ..., padding: bool = ...): ... +def prompt_for_choice(choices, default: Any | None = ..., padding: bool = ...): ... +def prompt_for_input(question, default: Any | None = ..., padding: bool = ..., strip: bool = ...): ... +def prepare_prompt_text(prompt_text, **options): ... +def prepare_friendly_prompts() -> None: ... +def retry_limit(limit=...) -> None: ... + +class TooManyInvalidReplies(Exception): ... diff --git a/stubs/humanfriendly/humanfriendly/sphinx.pyi b/stubs/humanfriendly/humanfriendly/sphinx.pyi new file mode 100644 index 000000000..eb6a63543 --- /dev/null +++ b/stubs/humanfriendly/humanfriendly/sphinx.pyi @@ -0,0 +1,15 @@ +from typing import Any + +logger: Any + +def deprecation_note_callback(app, what, name, obj, options, lines) -> None: ... +def enable_deprecation_notes(app) -> None: ... +def enable_man_role(app) -> None: ... +def enable_pypi_role(app) -> None: ... +def enable_special_methods(app) -> None: ... +def enable_usage_formatting(app) -> None: ... +def man_role(role, rawtext, text, lineno, inliner, options=..., content=...): ... +def pypi_role(role, rawtext, text, lineno, inliner, options=..., content=...): ... +def setup(app): ... +def special_methods_callback(app, what, name, obj, skip, options): ... +def usage_message_callback(app, what, name, obj, options, lines) -> None: ... diff --git a/stubs/humanfriendly/humanfriendly/tables.pyi b/stubs/humanfriendly/humanfriendly/tables.pyi new file mode 100644 index 000000000..0b324b1f3 --- /dev/null +++ b/stubs/humanfriendly/humanfriendly/tables.pyi @@ -0,0 +1,6 @@ +from typing import Any + +def format_smart_table(data, column_names): ... +def format_pretty_table(data, column_names: Any | None = ..., horizontal_bar: str = ..., vertical_bar: str = ...): ... +def format_robust_table(data, column_names): ... +def format_rst_table(data, column_names: Any | None = ...): ... diff --git a/stubs/humanfriendly/humanfriendly/terminal/__init__.pyi b/stubs/humanfriendly/humanfriendly/terminal/__init__.pyi new file mode 100644 index 000000000..8c94e18c0 --- /dev/null +++ b/stubs/humanfriendly/humanfriendly/terminal/__init__.pyi @@ -0,0 +1,37 @@ +from typing import Any + +ANSI_CSI: str +ANSI_SGR: str +ANSI_ERASE_LINE: Any +ANSI_RESET: Any +ANSI_HIDE_CURSOR: Any +ANSI_SHOW_CURSOR: Any +ANSI_COLOR_CODES: Any +ANSI_TEXT_STYLES: Any +CLEAN_OUTPUT_PATTERN: Any +DEFAULT_LINES: int +DEFAULT_COLUMNS: int +DEFAULT_ENCODING: str +HIGHLIGHT_COLOR: Any + +def ansi_strip(text, readline_hints: bool = ...): ... +def ansi_style(**kw): ... +def ansi_width(text): ... +def ansi_wrap(text, **kw): ... +def auto_encode(stream, text, *args, **kw) -> None: ... +def clean_terminal_output(text): ... +def connected_to_terminal(stream: Any | None = ...): ... +def enable_ansi_support(): ... +def find_terminal_size(): ... +def find_terminal_size_using_ioctl(stream): ... +def find_terminal_size_using_stty(): ... +def get_pager_command(text: Any | None = ...): ... +def have_windows_native_ansi_support(): ... +def message(text, *args, **kw) -> None: ... +def output(text, *args, **kw) -> None: ... +def readline_strip(expr): ... +def readline_wrap(expr): ... +def show_pager(formatted_text, encoding=...) -> None: ... +def terminal_supports_colors(stream: Any | None = ...): ... +def usage(usage_text) -> None: ... +def warning(text, *args, **kw) -> None: ... diff --git a/stubs/humanfriendly/humanfriendly/terminal/html.pyi b/stubs/humanfriendly/humanfriendly/terminal/html.pyi new file mode 100644 index 000000000..ad1907b1e --- /dev/null +++ b/stubs/humanfriendly/humanfriendly/terminal/html.pyi @@ -0,0 +1,31 @@ +from typing import Any + +from humanfriendly.compat import HTMLParser + +def html_to_ansi(data, callback: Any | None = ...): ... + +class HTMLConverter(HTMLParser): + BLOCK_TAGS: Any + callback: Any + output: Any + def __init__(self, *args, **kw) -> None: ... + def __call__(self, data): ... + @property + def current_style(self): ... + stack: Any + def close(self) -> None: ... + def emit_style(self, style: Any | None = ...) -> None: ... + def handle_charref(self, value) -> None: ... + link_text: Any + def handle_data(self, data) -> None: ... + def handle_endtag(self, tag) -> None: ... + def handle_entityref(self, name) -> None: ... + link_url: Any + def handle_starttag(self, tag, attrs) -> None: ... + def normalize_url(self, url): ... + def parse_color(self, value): ... + def push_styles(self, **changes) -> None: ... + def render_url(self, url): ... + preformatted_text_level: int + def reset(self) -> None: ... + def urls_match(self, a, b): ... diff --git a/stubs/humanfriendly/humanfriendly/terminal/spinners.pyi b/stubs/humanfriendly/humanfriendly/terminal/spinners.pyi new file mode 100644 index 000000000..091ac7c27 --- /dev/null +++ b/stubs/humanfriendly/humanfriendly/terminal/spinners.pyi @@ -0,0 +1,30 @@ +from typing import Any + +GLYPHS: Any +MINIMUM_INTERVAL: float + +class Spinner: + interactive: Any + interval: Any + label: Any + states: Any + stream: Any + timer: Any + total: Any + counter: int + last_update: int + def __init__(self, **options) -> None: ... + def step(self, progress: int = ..., label: Any | None = ...) -> None: ... + def sleep(self) -> None: ... + def clear(self) -> None: ... + def __enter__(self): ... + def __exit__(self, exc_type: Any | None = ..., exc_value: Any | None = ..., traceback: Any | None = ...) -> None: ... + +class AutomaticSpinner: + label: Any + show_time: Any + shutdown_event: Any + subprocess: Any + def __init__(self, label, show_time: bool = ...) -> None: ... + def __enter__(self) -> None: ... + def __exit__(self, exc_type: Any | None = ..., exc_value: Any | None = ..., traceback: Any | None = ...) -> None: ... diff --git a/stubs/humanfriendly/humanfriendly/testing.pyi b/stubs/humanfriendly/humanfriendly/testing.pyi new file mode 100644 index 000000000..8da7c3178 --- /dev/null +++ b/stubs/humanfriendly/humanfriendly/testing.pyi @@ -0,0 +1,86 @@ +import unittest +from typing import Any + +from humanfriendly.compat import StringIO + +def configure_logging(log_level=...) -> None: ... +def make_dirs(pathname) -> None: ... +def retry(func, timeout: int = ..., exc_type=...): ... +def run_cli(entry_point, *arguments, **options): ... +def skip_on_raise(*exc_types): ... +def touch(filename) -> None: ... + +class CallableTimedOut(Exception): ... + +class ContextManager: + def __enter__(self): ... + def __exit__(self, exc_type: Any | None = ..., exc_value: Any | None = ..., traceback: Any | None = ...) -> None: ... + +class PatchedAttribute(ContextManager): + object_to_patch: Any + attribute_to_patch: Any + patched_value: Any + original_value: Any + def __init__(self, obj, name, value) -> None: ... + def __enter__(self): ... + def __exit__(self, exc_type: Any | None = ..., exc_value: Any | None = ..., traceback: Any | None = ...) -> None: ... + +class PatchedItem(ContextManager): + object_to_patch: Any + item_to_patch: Any + patched_value: Any + original_value: Any + def __init__(self, obj, item, value) -> None: ... + def __enter__(self): ... + def __exit__(self, exc_type: Any | None = ..., exc_value: Any | None = ..., traceback: Any | None = ...) -> None: ... + +class TemporaryDirectory(ContextManager): + mkdtemp_options: Any + temporary_directory: Any + def __init__(self, **options) -> None: ... + def __enter__(self): ... + def __exit__(self, exc_type: Any | None = ..., exc_value: Any | None = ..., traceback: Any | None = ...) -> None: ... + +class MockedHomeDirectory(PatchedItem, TemporaryDirectory): + def __init__(self) -> None: ... + patched_value: Any + def __enter__(self): ... + def __exit__(self, exc_type: Any | None = ..., exc_value: Any | None = ..., traceback: Any | None = ...) -> None: ... + +class CustomSearchPath(PatchedItem, TemporaryDirectory): + isolated_search_path: Any + def __init__(self, isolated: bool = ...) -> None: ... + patched_value: Any + def __enter__(self): ... + def __exit__(self, exc_type: Any | None = ..., exc_value: Any | None = ..., traceback: Any | None = ...) -> None: ... + @property + def current_search_path(self): ... + +class MockedProgram(CustomSearchPath): + program_name: Any + program_returncode: Any + program_script: Any + program_signal_file: Any + def __init__(self, name, returncode: int = ..., script: Any | None = ...) -> None: ... + def __enter__(self): ... + def __exit__(self, *args, **kw): ... + +class CaptureOutput(ContextManager): + stdin: Any + stdout: Any + stderr: Any + patched_attributes: Any + def __init__(self, merged: bool = ..., input: str = ..., enabled: bool = ...) -> None: ... + def __enter__(self): ... + def __exit__(self, exc_type: Any | None = ..., exc_value: Any | None = ..., traceback: Any | None = ...) -> None: ... + def get_lines(self): ... + def get_text(self): ... + def getvalue(self): ... + +class CaptureBuffer(StringIO): + def get_lines(self): ... + def get_text(self): ... + +class TestCase(unittest.TestCase): + def __init__(self, *args, **kw) -> None: ... + def setUp(self, log_level=...) -> None: ... diff --git a/stubs/humanfriendly/humanfriendly/text.pyi b/stubs/humanfriendly/humanfriendly/text.pyi new file mode 100644 index 000000000..9c58cff14 --- /dev/null +++ b/stubs/humanfriendly/humanfriendly/text.pyi @@ -0,0 +1,17 @@ +from typing import Any + +def compact(text, *args, **kw): ... +def compact_empty_lines(text): ... +def concatenate(items, conjunction: str = ..., serial_comma: bool = ...): ... +def dedent(text, *args, **kw): ... +def format(text, *args, **kw): ... +def generate_slug(text, delimiter: str = ...): ... +def is_empty_line(text): ... +def join_lines(text): ... +def pluralize(count, singular, plural: Any | None = ...): ... +def pluralize_raw(count, singular, plural: Any | None = ...): ... +def random_string(length=..., characters=...): ... +def split(text, delimiter: str = ...): ... +def split_paragraphs(text): ... +def tokenize(text): ... +def trim_empty_lines(text): ... diff --git a/stubs/humanfriendly/humanfriendly/usage.pyi b/stubs/humanfriendly/humanfriendly/usage.pyi new file mode 100644 index 000000000..9ebfb108f --- /dev/null +++ b/stubs/humanfriendly/humanfriendly/usage.pyi @@ -0,0 +1,7 @@ +USAGE_MARKER: str + +def format_usage(usage_text): ... +def find_meta_variables(usage_text): ... +def parse_usage(text): ... +def render_usage(text): ... +def inject_usage(module_name) -> None: ...