From fb0176bbebfff021a46ad9337c573704cb7769f4 Mon Sep 17 00:00:00 2001 From: TuringTux Date: Sat, 31 Jan 2026 13:35:53 +0100 Subject: [PATCH 01/56] Autogenerate stubs using scripts/create_baseline_stubs.py weasyprint --- pyrightconfig.stricter.json | 1 + stubs/weasyprint/METADATA.toml | 2 + stubs/weasyprint/weasyprint/__init__.pyi | 83 ++++++ stubs/weasyprint/weasyprint/anchors.pyi | 3 + stubs/weasyprint/weasyprint/css/__init__.pyi | 106 ++++++++ .../weasyprint/css/computed_values.pyi | 47 ++++ stubs/weasyprint/weasyprint/css/counters.pyi | 8 + stubs/weasyprint/weasyprint/css/functions.pyi | 15 ++ .../weasyprint/css/media_queries.pyi | 2 + .../weasyprint/weasyprint/css/properties.pyi | 13 + stubs/weasyprint/weasyprint/css/targets.pyi | 35 +++ stubs/weasyprint/weasyprint/css/tokens.pyi | 55 ++++ stubs/weasyprint/weasyprint/css/units.pyi | 12 + .../weasyprint/css/validation/__init__.pyi | 8 + .../weasyprint/css/validation/descriptors.pyi | 49 ++++ .../weasyprint/css/validation/expanders.pyi | 45 ++++ .../weasyprint/css/validation/properties.pyi | 249 ++++++++++++++++++ stubs/weasyprint/weasyprint/document.pyi | 31 +++ stubs/weasyprint/weasyprint/draw/__init__.pyi | 11 + stubs/weasyprint/weasyprint/draw/border.pyi | 14 + stubs/weasyprint/weasyprint/draw/color.pyi | 4 + stubs/weasyprint/weasyprint/draw/text.pyi | 4 + stubs/weasyprint/weasyprint/html.pyi | 32 +++ stubs/weasyprint/weasyprint/images.pyi | 66 +++++ .../weasyprint/weasyprint/layout/__init__.pyi | 49 ++++ .../weasyprint/weasyprint/layout/absolute.pyi | 17 ++ .../weasyprint/layout/background.pyi | 22 ++ stubs/weasyprint/weasyprint/layout/block.pyi | 73 +++++ stubs/weasyprint/weasyprint/layout/column.pyi | 13 + stubs/weasyprint/weasyprint/layout/flex.pyi | 5 + stubs/weasyprint/weasyprint/layout/float.pyi | 8 + stubs/weasyprint/weasyprint/layout/grid.pyi | 1 + stubs/weasyprint/weasyprint/layout/inline.pyi | 80 ++++++ stubs/weasyprint/weasyprint/layout/leader.pyi | 2 + .../weasyprint/weasyprint/layout/min_max.pyi | 2 + stubs/weasyprint/weasyprint/layout/page.pyi | 67 +++++ .../weasyprint/weasyprint/layout/percent.pyi | 6 + .../weasyprint/layout/preferred.pyi | 27 ++ .../weasyprint/weasyprint/layout/replaced.pyi | 18 ++ stubs/weasyprint/weasyprint/layout/table.pyi | 23 ++ stubs/weasyprint/weasyprint/logger.pyi | 14 + stubs/weasyprint/weasyprint/matrix.pyi | 10 + stubs/weasyprint/weasyprint/pdf/__init__.pyi | 5 + stubs/weasyprint/weasyprint/pdf/anchors.pyi | 9 + stubs/weasyprint/weasyprint/pdf/debug.pyi | 5 + stubs/weasyprint/weasyprint/pdf/fonts.pyi | 38 +++ stubs/weasyprint/weasyprint/pdf/metadata.pyi | 32 +++ stubs/weasyprint/weasyprint/pdf/pdfa.pyi | 5 + stubs/weasyprint/weasyprint/pdf/pdfua.pyi | 5 + stubs/weasyprint/weasyprint/pdf/pdfx.pyi | 5 + stubs/weasyprint/weasyprint/pdf/stream.pyi | 41 +++ stubs/weasyprint/weasyprint/pdf/tags.pyi | 1 + stubs/weasyprint/weasyprint/stacking.pyi | 17 ++ stubs/weasyprint/weasyprint/svg/__init__.pyi | 86 ++++++ .../weasyprint/svg/bounding_box.pyi | 18 ++ stubs/weasyprint/weasyprint/svg/css.pyi | 6 + stubs/weasyprint/weasyprint/svg/defs.pyi | 10 + stubs/weasyprint/weasyprint/svg/images.pyi | 2 + stubs/weasyprint/weasyprint/svg/path.pyi | 3 + stubs/weasyprint/weasyprint/svg/shapes.pyi | 6 + stubs/weasyprint/weasyprint/svg/text.pyi | 12 + stubs/weasyprint/weasyprint/svg/utils.pyi | 10 + stubs/weasyprint/weasyprint/urls.pyi | 72 +++++ 63 files changed, 1720 insertions(+) create mode 100644 stubs/weasyprint/METADATA.toml create mode 100644 stubs/weasyprint/weasyprint/__init__.pyi create mode 100644 stubs/weasyprint/weasyprint/anchors.pyi create mode 100644 stubs/weasyprint/weasyprint/css/__init__.pyi create mode 100644 stubs/weasyprint/weasyprint/css/computed_values.pyi create mode 100644 stubs/weasyprint/weasyprint/css/counters.pyi create mode 100644 stubs/weasyprint/weasyprint/css/functions.pyi create mode 100644 stubs/weasyprint/weasyprint/css/media_queries.pyi create mode 100644 stubs/weasyprint/weasyprint/css/properties.pyi create mode 100644 stubs/weasyprint/weasyprint/css/targets.pyi create mode 100644 stubs/weasyprint/weasyprint/css/tokens.pyi create mode 100644 stubs/weasyprint/weasyprint/css/units.pyi create mode 100644 stubs/weasyprint/weasyprint/css/validation/__init__.pyi create mode 100644 stubs/weasyprint/weasyprint/css/validation/descriptors.pyi create mode 100644 stubs/weasyprint/weasyprint/css/validation/expanders.pyi create mode 100644 stubs/weasyprint/weasyprint/css/validation/properties.pyi create mode 100644 stubs/weasyprint/weasyprint/document.pyi create mode 100644 stubs/weasyprint/weasyprint/draw/__init__.pyi create mode 100644 stubs/weasyprint/weasyprint/draw/border.pyi create mode 100644 stubs/weasyprint/weasyprint/draw/color.pyi create mode 100644 stubs/weasyprint/weasyprint/draw/text.pyi create mode 100644 stubs/weasyprint/weasyprint/html.pyi create mode 100644 stubs/weasyprint/weasyprint/images.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/__init__.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/absolute.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/background.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/block.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/column.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/flex.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/float.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/grid.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/inline.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/leader.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/min_max.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/page.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/percent.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/preferred.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/replaced.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/table.pyi create mode 100644 stubs/weasyprint/weasyprint/logger.pyi create mode 100644 stubs/weasyprint/weasyprint/matrix.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/__init__.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/anchors.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/debug.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/fonts.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/metadata.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/pdfa.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/pdfua.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/pdfx.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/stream.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/tags.pyi create mode 100644 stubs/weasyprint/weasyprint/stacking.pyi create mode 100644 stubs/weasyprint/weasyprint/svg/__init__.pyi create mode 100644 stubs/weasyprint/weasyprint/svg/bounding_box.pyi create mode 100644 stubs/weasyprint/weasyprint/svg/css.pyi create mode 100644 stubs/weasyprint/weasyprint/svg/defs.pyi create mode 100644 stubs/weasyprint/weasyprint/svg/images.pyi create mode 100644 stubs/weasyprint/weasyprint/svg/path.pyi create mode 100644 stubs/weasyprint/weasyprint/svg/shapes.pyi create mode 100644 stubs/weasyprint/weasyprint/svg/text.pyi create mode 100644 stubs/weasyprint/weasyprint/svg/utils.pyi create mode 100644 stubs/weasyprint/weasyprint/urls.pyi diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index 7afdcc3eab14..02148522fdce 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -92,6 +92,7 @@ "stubs/tensorflow", "stubs/tqdm", "stubs/vobject", + "stubs/weasyprint", "stubs/workalendar", "stubs/xmldiff", ], diff --git a/stubs/weasyprint/METADATA.toml b/stubs/weasyprint/METADATA.toml new file mode 100644 index 000000000000..19d025730564 --- /dev/null +++ b/stubs/weasyprint/METADATA.toml @@ -0,0 +1,2 @@ +version = "68.0.*" +upstream_repository = "https://github.com/Kozea/WeasyPrint" diff --git a/stubs/weasyprint/weasyprint/__init__.pyi b/stubs/weasyprint/weasyprint/__init__.pyi new file mode 100644 index 000000000000..49a49a8964f4 --- /dev/null +++ b/stubs/weasyprint/weasyprint/__init__.pyi @@ -0,0 +1,83 @@ +from _typeshed import Incomplete + +from .document import Document as Document, Page as Page +from .urls import default_url_fetcher as default_url_fetcher + +__all__ = ["CSS", "DEFAULT_OPTIONS", "HTML", "VERSION", "Attachment", "Document", "Page", "__version__", "default_url_fetcher"] + +VERSION: str +__version__: str +DEFAULT_OPTIONS: Incomplete + +class HTML: + base_url: Incomplete + url_fetcher: Incomplete + media_type: Incomplete + wrapper_element: Incomplete + etree_element: Incomplete + def __init__( + self, + guess=None, + filename=None, + url=None, + file_obj=None, + string=None, + encoding=None, + base_url=None, + url_fetcher=None, + media_type: str = "print", + ) -> None: ... + def render(self, font_config=None, counter_style=None, color_profiles=None, **options): ... + def write_pdf( + self, target=None, zoom: int = 1, finisher=None, font_config=None, counter_style=None, color_profiles=None, **options + ): ... + +class CSS: + base_url: Incomplete + matcher: Incomplete + page_rules: Incomplete + layers: Incomplete + def __init__( + self, + guess=None, + filename=None, + url=None, + file_obj=None, + string=None, + encoding=None, + base_url=None, + url_fetcher=None, + _check_mime_type: bool = False, + media_type: str = "print", + font_config=None, + counter_style=None, + color_profiles=None, + matcher=None, + page_rules=None, + layers=None, + layer=None, + ) -> None: ... + +class Attachment: + source: Incomplete + name: Incomplete + description: Incomplete + relationship: Incomplete + md5: Incomplete + created: Incomplete + modified: Incomplete + def __init__( + self, + guess=None, + filename=None, + url=None, + file_obj=None, + string=None, + base_url=None, + url_fetcher=None, + name=None, + description=None, + created=None, + modified=None, + relationship: str = "Unspecified", + ) -> None: ... diff --git a/stubs/weasyprint/weasyprint/anchors.pyi b/stubs/weasyprint/weasyprint/anchors.pyi new file mode 100644 index 000000000000..1ea4962b7bd4 --- /dev/null +++ b/stubs/weasyprint/weasyprint/anchors.pyi @@ -0,0 +1,3 @@ +def rectangle_aabb(matrix, pos_x, pos_y, width, height): ... +def gather_anchors(box, anchors, links, bookmarks, forms, parent_matrix=None, parent_form=None) -> None: ... +def make_page_bookmark_tree(page, skipped_levels, last_by_depth, previous_level, page_number, matrix): ... diff --git a/stubs/weasyprint/weasyprint/css/__init__.pyi b/stubs/weasyprint/weasyprint/css/__init__.pyi new file mode 100644 index 000000000000..0632f5edb8ba --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/__init__.pyi @@ -0,0 +1,106 @@ +from _typeshed import Incomplete +from collections.abc import Generator +from typing import NamedTuple + +PSEUDO_ELEMENTS: Incomplete + +class PageSelectorType(NamedTuple): + side: Incomplete + blank: Incomplete + first: Incomplete + index: Incomplete + name: Incomplete + +class StyleFor: + font_config: Incomplete + def __init__(self, html, sheets, presentational_hints, font_config, target_collector) -> None: ... + def __call__(self, element, pseudo_type=None): ... + def set_computed_styles(self, element, parent, root=None, pseudo_type=None, base_url=None, target_collector=None) -> None: ... + def add_page_declarations(self, page_type) -> None: ... + def get_cascaded_styles(self): ... + def get_computed_styles(self): ... + +def get_child_text(element): ... +def text_decoration(key, value, parent_value, cascaded): ... +def find_stylesheets( + wrapper_element, device_media_type, url_fetcher, base_url, font_config, counter_style, color_profiles, page_rules, layers +) -> Generator[Incomplete]: ... +def find_style_attributes(tree, presentational_hints: bool = False, base_url=None) -> Generator[Incomplete, None, Incomplete]: ... +def declaration_precedence(origin, importance): ... +def resolve_var(computed, token, parent_style, known_variables=None): ... +def resolve_math(token, computed=None, property_name=None, refer_to=None): ... + +class InitialStyle(dict): + parent_style: Incomplete + specified: Incomplete + cache: Incomplete + font_config: Incomplete + def __init__(self, font_config) -> None: ... + def __missing__(self, key): ... + +class AnonymousStyle(dict): + parent_style: Incomplete + is_root_element: bool + specified: Incomplete + cache: Incomplete + font_config: Incomplete + def __init__(self, parent_style) -> None: ... + def copy(self): ... + def __missing__(self, key): ... + +class ComputedStyle(dict): + specified: Incomplete + parent_style: Incomplete + cascaded: Incomplete + is_root_element: Incomplete + element: Incomplete + pseudo_type: Incomplete + root_style: Incomplete + base_url: Incomplete + font_config: Incomplete + cache: Incomplete + def __init__(self, parent_style, cascaded, element, pseudo_type, root_style, base_url, font_config) -> None: ... + def copy(self): ... + def __missing__(self, key): ... + +class ColorProfile: + src: Incomplete + renderingintent: Incomplete + components: Incomplete + def __init__(self, file_object, descriptors) -> None: ... + @property + def name(self): ... + @property + def content(self): ... + +def computed_from_cascaded( + element, cascaded, parent_style, pseudo_type=None, root_style=None, base_url=None, target_collector=None +): ... +def parse_color_profile_name(prelude): ... +def parse_page_selectors(rule): ... +def preprocess_stylesheet( + device_media_type, + base_url, + stylesheet_rules, + url_fetcher, + matcher, + page_rules, + layers, + font_config, + counter_style, + color_profiles, + ignore_imports: bool = False, + layer=None, +): ... +def get_all_computed_styles( + html, + user_stylesheets=None, + presentational_hints: bool = False, + font_config=None, + counter_style=None, + color_profiles=None, + page_rules=None, + layers=None, + target_collector=None, + forms: bool = False, +): ... diff --git a/stubs/weasyprint/weasyprint/css/computed_values.pyi b/stubs/weasyprint/weasyprint/css/computed_values.pyi new file mode 100644 index 000000000000..7a4373caabbb --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/computed_values.pyi @@ -0,0 +1,47 @@ +from _typeshed import Incomplete + +FONT_SIZE_KEYWORDS: Incomplete +BORDER_WIDTH_KEYWORDS: Incomplete +FONT_WEIGHT_RELATIVE: Incomplete +PAGE_SIZES: Incomplete +INITIAL_PAGE_SIZE: Incomplete +COMPUTER_FUNCTIONS: Incomplete + +def register_computer(name): ... +def compute_attr(style, values): ... +def background_image(style, name, values): ... +def color(style, name, values): ... +def compute_position(style, name, values): ... +def length_or_percentage_tuple(style, name, values): ... +def length_tuple(style, name, values): ... +def break_before_after(style, name, value): ... +def length(style, name, value, font_size=None, pixels_only: bool = False): ... +def bleed(style, name, value): ... +def pixel_length(style, name, value): ... +def background_size(style, name, values): ... +def image_orientation(style, name, values): ... +def border_width(style, name, value): ... +def border_image_slice(style, name, values): ... +def border_image_width(style, name, values): ... +def border_image_outset(style, name, values): ... +def border_image_repeat(style, name, values): ... +def length_pixels_only(style, name, value): ... +def border_radius(style, name, values): ... +def gap(style, name, value): ... +def bookmark_label(style, name, values): ... +def string_set(style, name, values): ... +def content(style, name, values): ... +def display(style, name, value): ... +def compute_float(style, name, value): ... +def font_size(style, name, value): ... +def font_weight(style, name, value): ... +def grid_template(style, name, values): ... +def grid_auto(style, name, values): ... +def line_height(style, name, value): ... +def anchor(style, name, values): ... +def link(style, name, values): ... +def lang(style, name, values): ... +def tab_size(style, name, value): ... +def transform(style, name, value): ... +def vertical_align(style, name, value): ... +def word_spacing(style, name, value): ... diff --git a/stubs/weasyprint/weasyprint/css/counters.pyi b/stubs/weasyprint/weasyprint/css/counters.pyi new file mode 100644 index 000000000000..3ce81b8ecf7d --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/counters.pyi @@ -0,0 +1,8 @@ +def symbol(string_or_url): ... +def parse_counter_style_name(tokens, counter_style): ... + +class CounterStyle(dict): + def resolve_counter(self, counter_name, previous_types=None): ... + def render_value(self, counter_value, counter_name=None, counter=None, previous_types=None): ... + def render_marker(self, counter_name, counter_value): ... + def copy(self): ... diff --git a/stubs/weasyprint/weasyprint/css/functions.pyi b/stubs/weasyprint/weasyprint/css/functions.pyi new file mode 100644 index 000000000000..0adba4f045c7 --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/functions.pyi @@ -0,0 +1,15 @@ +from _typeshed import Incomplete + +class Function: + name: Incomplete + arguments: Incomplete + def __init__(self, token) -> None: ... + def split_space(self): ... + def split_comma(self, single_tokens: bool = True, trailing: bool = False): ... + +def check_attr(token, allowed_type=None): ... +def check_counter(token, allowed_type=None): ... +def check_content(token): ... +def check_string_or_element(string_or_element, token): ... +def check_var(token): ... +def check_math(token): ... diff --git a/stubs/weasyprint/weasyprint/css/media_queries.pyi b/stubs/weasyprint/weasyprint/css/media_queries.pyi new file mode 100644 index 000000000000..ca443734ce87 --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/media_queries.pyi @@ -0,0 +1,2 @@ +def evaluate_media_query(query_list, device_media_type): ... +def parse_media_query(tokens): ... diff --git a/stubs/weasyprint/weasyprint/css/properties.pyi b/stubs/weasyprint/weasyprint/css/properties.pyi new file mode 100644 index 000000000000..1983a5c3405f --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/properties.pyi @@ -0,0 +1,13 @@ +from _typeshed import Incomplete +from typing import NamedTuple + +class Dimension(NamedTuple): + value: Incomplete + unit: Incomplete + +ZERO_PIXELS: Incomplete +INITIAL_VALUES: Incomplete +KNOWN_PROPERTIES: Incomplete +INHERITED: Incomplete +TABLE_WRAPPER_BOX_PROPERTIES: Incomplete +INITIAL_NOT_COMPUTED: Incomplete diff --git a/stubs/weasyprint/weasyprint/css/targets.pyi b/stubs/weasyprint/weasyprint/css/targets.pyi new file mode 100644 index 000000000000..94356f9a3ab2 --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/targets.pyi @@ -0,0 +1,35 @@ +from _typeshed import Incomplete + +class TargetLookupItem: + state: Incomplete + target_box: Incomplete + parse_again_functions: Incomplete + page_maker_index: Incomplete + cached_page_counter_values: Incomplete + def __init__(self, state: str = "pending") -> None: ... + +class CounterLookupItem: + parse_again: Incomplete + missing_counters: Incomplete + missing_target_counters: Incomplete + page_maker_index: Incomplete + pending: bool + cached_page_counter_values: Incomplete + def __init__(self, parse_again, missing_counters, missing_target_counters) -> None: ... + +def anchor_name_from_token(anchor_token): ... + +class TargetCollector: + target_lookup_items: Incomplete + counter_lookup_items: Incomplete + collecting: bool + had_pending_targets: bool + def __init__(self) -> None: ... + def collect_anchor(self, anchor_name) -> None: ... + def lookup_target(self, anchor_token, source_box, css_token, parse_again): ... + def store_target(self, anchor_name, target_counter_values, target_box) -> None: ... + def collect_missing_counters( + self, parent_box, css_token, parse_again_function, missing_counters, missing_target_counters + ) -> None: ... + def check_pending_targets(self) -> None: ... + def cache_target_page_counters(self, anchor_name, page_counter_values, page_maker_index, page_maker) -> None: ... diff --git a/stubs/weasyprint/weasyprint/css/tokens.pyi b/stubs/weasyprint/weasyprint/css/tokens.pyi new file mode 100644 index 000000000000..59a6b55b3963 --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/tokens.pyi @@ -0,0 +1,55 @@ +import abc +from _typeshed import Incomplete +from abc import ABC, abstractmethod + +ZERO_PERCENT: Incomplete +FIFTY_PERCENT: Incomplete +HUNDRED_PERCENT: Incomplete +BACKGROUND_POSITION_PERCENTAGES: Incomplete +DIRECTION_KEYWORDS: Incomplete +E: Incomplete +PI: Incomplete +PLUS_INFINITY: Incomplete +MINUS_INFINITY: Incomplete +NAN: Incomplete + +class InvalidValues(ValueError): ... +class PercentageInMath(ValueError): ... +class FontUnitInMath(ValueError): ... + +class Pending(ABC, metaclass=abc.ABCMeta): + tokens: Incomplete + name: Incomplete + def __init__(self, tokens, name) -> None: ... + @abstractmethod + def validate(self, tokens, wanted_key): ... + def solve(self, tokens, wanted_key): ... + +def parse_color_hint(tokens): ... +def parse_color_stop(tokens): ... +def parse_color_stops_and_hints(color_stops_hints): ... +def parse_linear_gradient_parameters(arguments): ... +def parse_2d_position(tokens): ... +def parse_position(tokens): ... +def parse_radial_gradient_parameters(arguments): ... +def split_on_comma(tokens): ... +def remove_whitespace(tokens): ... +def get_keyword(token): ... +def get_custom_ident(token): ... +def get_single_keyword(tokens): ... +def get_number(token, negative: bool = True, integer: bool = False): ... +def get_string(token): ... +def get_percentage(token, negative: bool = True): ... +def get_length(token, negative: bool = True, percentage: bool = False): ... +def get_angle(token): ... +def get_resolution(token): ... +def get_image(token, base_url): ... +def get_url(token, base_url): ... +def get_quote(token): ... +def get_target(token, base_url): ... +def get_content_list(tokens, base_url): ... +def get_content_list_token(token, base_url): ... +def single_keyword(function): ... +def single_token(function): ... +def comma_separated_list(function): ... +def tokenize(item, function=None, unit=None): ... diff --git a/stubs/weasyprint/weasyprint/css/units.pyi b/stubs/weasyprint/weasyprint/css/units.pyi new file mode 100644 index 000000000000..d761e2255dca --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/units.pyi @@ -0,0 +1,12 @@ +from _typeshed import Incomplete + +ANGLE_TO_RADIANS: Incomplete +LENGTHS_TO_PIXELS: Incomplete +RESOLUTION_TO_DPPX: Incomplete +FONT_UNITS: Incomplete +ABSOLUTE_UNITS: Incomplete +LENGTH_UNITS = ABSOLUTE_UNITS | FONT_UNITS +ANGLE_UNITS: Incomplete + +def to_pixels(value, style, property_name, font_size=None): ... +def to_radians(value): ... diff --git a/stubs/weasyprint/weasyprint/css/validation/__init__.pyi b/stubs/weasyprint/weasyprint/css/validation/__init__.pyi new file mode 100644 index 000000000000..a67563c1b071 --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/validation/__init__.pyi @@ -0,0 +1,8 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +NOT_PRINT_MEDIA: Incomplete +NESTING_SELECTOR: Incomplete +ROOT_TOKEN: Incomplete + +def preprocess_declarations(base_url, declarations, prelude=None) -> Generator[Incomplete, Incomplete]: ... diff --git a/stubs/weasyprint/weasyprint/css/validation/descriptors.pyi b/stubs/weasyprint/weasyprint/css/validation/descriptors.pyi new file mode 100644 index 000000000000..43d34c46c0ea --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/validation/descriptors.pyi @@ -0,0 +1,49 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +from ..tokens import comma_separated_list, single_keyword, single_token + +DESCRIPTORS: Incomplete +NOT_PRINT_MEDIA: Incomplete + +class NoneFakeToken: + type: str + lower_value: str + +class NormalFakeToken: + type: str + lower_value: str + +def preprocess_descriptors(rule, base_url, descriptors) -> Generator[Incomplete]: ... +def descriptor(rule, descriptor_name=None, wants_base_url: bool = False): ... +def expand_font_variant(tokens) -> Generator[Incomplete]: ... +def font_family(tokens, allow_spaces: bool = False): ... +@comma_separated_list +def src(tokens, base_url): ... +@single_keyword +def font_style(keyword): ... +@single_token +def font_weight(token): ... +@single_keyword +def font_stretch(keyword): ... +def font_feature_settings(tokens): ... +def font_variant(tokens): ... +@comma_separated_list +@single_token +def unicode_range(token): ... +def system(tokens): ... +def negative(tokens, base_url): ... +def prefix_suffix(tokens, base_url): ... +@comma_separated_list +def range(tokens): ... +def pad(tokens, base_url): ... +@single_token +def fallback(token): ... +def symbols(tokens, base_url): ... +def additive_symbols(tokens, base_url): ... +@single_token +def color_profile_src(token, base_url): ... +@single_keyword +def rendering_intent(keyword): ... +@comma_separated_list +def components(tokens): ... diff --git a/stubs/weasyprint/weasyprint/css/validation/expanders.pyi b/stubs/weasyprint/weasyprint/css/validation/expanders.pyi new file mode 100644 index 000000000000..6e5133d3aaa4 --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/validation/expanders.pyi @@ -0,0 +1,45 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +from ..tokens import Pending + +EXPANDERS: Incomplete + +class PendingExpander(Pending): + validator: Incomplete + def __init__(self, tokens, validator) -> None: ... + def validate(self, tokens, wanted_key): ... + +def expander(property_name): ... +def generic_expander(*expanded_names, **kwargs): ... +def expand_four_sides(tokens, name, base_url) -> Generator[Incomplete, Incomplete]: ... +def border_radius(tokens, name, base_url) -> Generator[Incomplete]: ... +def expand_list_style(tokens, name, base_url) -> Generator[Incomplete]: ... +def expand_border(tokens, name, base_url) -> Generator[Incomplete, Incomplete]: ... +def expand_border_side(tokens, name) -> Generator[Incomplete]: ... +def expand_border_image(tokens, name, base_url) -> Generator[Incomplete]: ... +def expand_mask_border(tokens, name, base_url) -> Generator[Incomplete]: ... +def expand_background(tokens, name, base_url) -> Generator[Incomplete, Incomplete, Incomplete]: ... +def expand_text_decoration(tokens, name) -> Generator[Incomplete]: ... +def expand_page_break_before_after(tokens, name) -> Generator[Incomplete]: ... +def expand_page_break_after(tokens, name): ... +def expand_page_break_before(tokens, name): ... +def expand_page_break_inside(tokens, name) -> Generator[Incomplete]: ... +def expand_columns(tokens, name) -> Generator[Incomplete]: ... +def font_variant(tokens, name): ... +def expand_font(tokens, name) -> Generator[Incomplete]: ... +def expand_word_wrap(tokens, name) -> Generator[Incomplete]: ... +def expand_flex(tokens, name) -> Generator[Incomplete]: ... +def expand_flex_flow(tokens, name) -> Generator[Incomplete]: ... +def expand_grid_template(tokens, name) -> Generator[Incomplete, Incomplete]: ... +def expand_grid(tokens, name) -> Generator[Incomplete]: ... +def expand_grid_column_row(tokens, name) -> Generator[Incomplete]: ... +def expand_grid_area(tokens, name) -> Generator[Incomplete]: ... +def expand_gap(tokens, name) -> Generator[Incomplete]: ... +def expand_legacy_column_gap(tokens, name) -> Generator[Incomplete]: ... +def expand_legacy_row_gap(tokens, name) -> Generator[Incomplete]: ... +def expand_place_content(tokens, name) -> None: ... +def expand_place_items(tokens, name) -> None: ... +def expand_place_self(tokens, name) -> None: ... +def expand_line_clamp(tokens, name) -> Generator[Incomplete]: ... +def expand_text_align(tokens, name) -> Generator[Incomplete]: ... diff --git a/stubs/weasyprint/weasyprint/css/validation/properties.pyi b/stubs/weasyprint/weasyprint/css/validation/properties.pyi new file mode 100644 index 000000000000..beabb5cd6d5d --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/validation/properties.pyi @@ -0,0 +1,249 @@ +from _typeshed import Incomplete + +from ..tokens import Pending, comma_separated_list, single_keyword, single_token + +PREFIX: str +PROPRIETARY: Incomplete +UNSTABLE: Incomplete +PROPERTIES: Incomplete + +class PendingProperty(Pending): + def validate(self, tokens, wanted_key): ... + +def property(property_name=None, proprietary: bool = False, unstable: bool = False, wants_base_url: bool = False): ... +def validate_non_shorthand(tokens, name, base_url=None, required: bool = False): ... +@comma_separated_list +@single_keyword +def background_attachment(keyword): ... +@single_token +def other_colors(token): ... +@single_token +def outline_color(token): ... +@single_keyword +def border_collapse(keyword): ... +@single_keyword +def empty_cells(keyword): ... +@single_token +def color(token): ... +@comma_separated_list +@single_token +def background_image(token, base_url): ... +@single_token +def list_style_image(token, base_url): ... +def transform_origin(tokens): ... +@comma_separated_list +def background_position(tokens): ... +@comma_separated_list +def object_position(tokens): ... +@comma_separated_list +def background_repeat(tokens): ... +@comma_separated_list +def background_size(tokens): ... +@comma_separated_list +@single_keyword +def box(keyword): ... +def border_spacing(tokens): ... +def border_corner_radius(tokens): ... +@single_keyword +def border_style(keyword): ... +@single_keyword +def break_before_after(keyword): ... +@single_keyword +def break_inside(keyword): ... +@single_keyword +def box_decoration_break(keyword): ... +@single_token +def block_ellipsis(token): ... +@single_keyword +def continue_(keyword): ... +@single_token +def max_lines(token): ... +@single_keyword +def margin_break(keyword): ... +@single_token +def page(token): ... +@single_token +def bleed(token): ... +def marks(tokens): ... +@single_keyword +def outline_style(keyword): ... +@single_token +def border_width(token): ... +@single_token +def border_image_source(token, base_url): ... +def border_image_slice(tokens): ... +def border_image_width(tokens): ... +def border_image_outset(tokens): ... +def border_image_repeat(tokens): ... +@single_keyword +def mask_border_mode(keyword): ... +@single_token +def column_width(token): ... +@single_keyword +def column_span(keyword): ... +@single_keyword +def box_sizing(keyword): ... +@single_keyword +def caption_side(keyword): ... +@single_keyword +def clear(keyword): ... +@single_token +def clip(token): ... +def content(tokens, base_url): ... +def counter_increment(tokens): ... +def counter_reset(tokens): ... +def counter_set(tokens): ... +def counter(tokens, default_integer): ... +@single_token +def lenght_precentage_or_auto(token): ... +@single_token +def width_height(token): ... +@single_token +def gap(token): ... +@single_keyword +def column_fill(keyword): ... +@single_keyword +def direction(keyword): ... +def display(tokens): ... +@single_keyword +def float_(keyword): ... +@comma_separated_list +def font_family(tokens): ... +@single_keyword +def font_kerning(keyword): ... +@single_token +def font_language_override(token): ... +def font_variant_ligatures(tokens): ... +@single_keyword +def font_variant_position(keyword): ... +@single_keyword +def font_variant_caps(keyword): ... +def font_variant_numeric(tokens): ... +def font_feature_settings(tokens): ... +@single_keyword +def font_variant_alternates(keyword): ... +def font_variant_east_asian(tokens): ... +def font_variation_settings(tokens): ... +@single_token +def font_size(token): ... +@single_keyword +def font_style(keyword): ... +@single_keyword +def font_stretch(keyword): ... +@single_token +def font_weight(token): ... +@single_keyword +def object_fit(keyword): ... +@single_token +def image_resolution(token): ... +@single_token +def spacing(token): ... +@single_token +def outline_offset(token): ... +@single_token +def line_height(token): ... +@single_keyword +def list_style_position(keyword): ... +@single_token +def list_style_type(token): ... +@single_token +def min_width_height(token): ... +@single_token +def length_or_precentage(token): ... +@single_token +def max_width_height(token): ... +@single_token +def opacity(token): ... +@single_token +def z_index(token): ... +@single_token +def orphans_widows(token): ... +@single_token +def column_count(token): ... +@single_keyword +def overflow(keyword): ... +@single_keyword +def text_overflow(keyword): ... +@single_token +def position(token): ... +def quotes(tokens): ... +@single_keyword +def table_layout(keyword): ... +@single_keyword +def text_align_all(keyword): ... +@single_keyword +def text_align_last(keyword): ... +def text_decoration_line(tokens): ... +@single_keyword +def text_decoration_style(keyword): ... +@single_token +def text_decoration_thickness(token): ... +@single_token +def text_indent(token): ... +@single_keyword +def text_transform(keyword): ... +@single_token +def vertical_align(token): ... +@single_keyword +def visibility(keyword): ... +@single_keyword +def white_space(keyword): ... +@single_keyword +def overflow_wrap(keyword): ... +@single_keyword +def word_break(keyword): ... +@single_token +def flex_basis(token): ... +@single_keyword +def flex_direction(keyword): ... +@single_token +def flex_grow_shrink(token): ... +def grid_auto(tokens): ... +def grid_auto_flow(tokens): ... +def grid_template(tokens): ... +def grid_template_areas(tokens): ... +def grid_line(tokens): ... +@single_keyword +def flex_wrap(keyword): ... +def justify_content(tokens): ... +def justify_items(tokens): ... +def justify_self(tokens): ... +def align_items(tokens): ... +def align_self(tokens): ... +def align_content(tokens): ... +@single_token +def order(token): ... +@single_keyword +def image_rendering(keyword): ... +def image_orientation(tokens): ... +def size(tokens): ... +@single_token +def anchor(token): ... +@single_token +def link(token, base_url): ... +@single_token +def tab_size(token): ... +@single_token +def hyphens(token): ... +@single_token +def hyphenate_character(token): ... +@single_token +def hyphenate_limit_zone(token): ... +def hyphenate_limit_chars(tokens): ... +@single_token +def lang(token): ... +def bookmark_label(tokens, base_url): ... +@single_token +def bookmark_level(token): ... +@single_keyword +def bookmark_state(keyword): ... +@single_keyword +def footnote_display(keyword): ... +@single_keyword +def footnote_policy(keyword): ... +@comma_separated_list +def string_set(tokens, base_url): ... +def transform(tokens): ... +@single_token +def appearance(token): ... +def color_scheme(tokens): ... diff --git a/stubs/weasyprint/weasyprint/document.pyi b/stubs/weasyprint/weasyprint/document.pyi new file mode 100644 index 000000000000..632001eade15 --- /dev/null +++ b/stubs/weasyprint/weasyprint/document.pyi @@ -0,0 +1,31 @@ +from _typeshed import Incomplete + +class Page: + width: Incomplete + height: Incomplete + bleed: Incomplete + bookmarks: Incomplete + links: Incomplete + anchors: Incomplete + forms: Incomplete + def __init__(self, page_box) -> None: ... + def paint(self, stream, scale: int = 1) -> None: ... + +class DiskCache: + def __init__(self, folder) -> None: ... + def __getitem__(self, key): ... + def __setitem__(self, key, value) -> None: ... + def __contains__(self, key) -> bool: ... + def __del__(self) -> None: ... + +class Document: + pages: Incomplete + metadata: Incomplete + url_fetcher: Incomplete + fonts: Incomplete + font_config: Incomplete + color_profiles: Incomplete + def __init__(self, pages, metadata, url_fetcher, font_config, color_profiles) -> None: ... + def copy(self, pages: str = "all"): ... + def make_bookmark_tree(self, scale: int = 1, transform_pages: bool = False): ... + def write_pdf(self, target=None, zoom: int = 1, finisher=None, **options): ... diff --git a/stubs/weasyprint/weasyprint/draw/__init__.pyi b/stubs/weasyprint/weasyprint/draw/__init__.pyi new file mode 100644 index 000000000000..4e1f46756edd --- /dev/null +++ b/stubs/weasyprint/weasyprint/draw/__init__.pyi @@ -0,0 +1,11 @@ +def draw_page(page, stream) -> None: ... +def draw_stacking_context(stream, stacking_context) -> None: ... +def draw_background(stream, bg, clip_box: bool = True, bleed=None, marks=()) -> None: ... +def draw_background_image(stream, layer, style) -> None: ... +def draw_table(stream, table): ... +def draw_collapsed_borders(stream, table): ... +def draw_replacedbox(stream, box) -> None: ... +def draw_inline_level( + stream, page, box, offset_x: int = 0, text_overflow: str = "clip", block_ellipsis: str = "none" +) -> None: ... +def draw_block_level(page, stream, blocks_and_cells) -> None: ... diff --git a/stubs/weasyprint/weasyprint/draw/border.pyi b/stubs/weasyprint/weasyprint/draw/border.pyi new file mode 100644 index 000000000000..4a91f968fb50 --- /dev/null +++ b/stubs/weasyprint/weasyprint/draw/border.pyi @@ -0,0 +1,14 @@ +from _typeshed import Incomplete + +SIDES: Incomplete + +def set_mask_border(stream, box) -> None: ... +def draw_column_rules(stream, box) -> None: ... +def draw_border(stream, box) -> None: ... +def draw_border_image(box, stream, image, border_slice, border_repeat, border_outset, border_width): ... +def clip_border_segment(stream, style, width, side, border_box, border_widths=None, radii=None): ... +def draw_rounded_border(stream, box, style, color) -> None: ... +def draw_rect_border(stream, box, widths, style, color) -> None: ... +def draw_line(stream, x1, y1, x2, y2, thickness, style, color, offset: int = 0) -> None: ... +def draw_outline(stream, box) -> None: ... +def rounded_box(stream, radii) -> None: ... diff --git a/stubs/weasyprint/weasyprint/draw/color.pyi b/stubs/weasyprint/weasyprint/draw/color.pyi new file mode 100644 index 000000000000..eafb78956314 --- /dev/null +++ b/stubs/weasyprint/weasyprint/draw/color.pyi @@ -0,0 +1,4 @@ +def get_color(style, key): ... +def darken(color): ... +def lighten(color): ... +def styled_color(style, color, side): ... diff --git a/stubs/weasyprint/weasyprint/draw/text.pyi b/stubs/weasyprint/weasyprint/draw/text.pyi new file mode 100644 index 000000000000..3137e41b372f --- /dev/null +++ b/stubs/weasyprint/weasyprint/draw/text.pyi @@ -0,0 +1,4 @@ +def draw_text(stream, textbox, offset_x, text_overflow, block_ellipsis) -> None: ... +def draw_emojis(stream, style, x, y, emojis) -> None: ... +def draw_first_line(stream, textbox, text_overflow, block_ellipsis, matrix): ... +def draw_text_decoration(stream, textbox, offset_x, offset_y, thickness, color) -> None: ... diff --git a/stubs/weasyprint/weasyprint/html.pyi b/stubs/weasyprint/weasyprint/html.pyi new file mode 100644 index 000000000000..1f7f93f77a4c --- /dev/null +++ b/stubs/weasyprint/weasyprint/html.pyi @@ -0,0 +1,32 @@ +from _typeshed import Incomplete + +HTML5_UA_COUNTER_STYLE: Incomplete +HTML5_UA: Incomplete +HTML5_UA_FORM: Incomplete +HTML5_PH: Incomplete +HTML5_UA_STYLESHEET: Incomplete +HTML5_UA_FORM_STYLESHEET: Incomplete +HTML5_PH_STYLESHEET: Incomplete +HTML_WHITESPACE: str +HTML_SPACE_SEPARATED_TOKENS_RE: Incomplete + +def ascii_lower(string): ... +def element_has_link_type(element, link_type): ... + +HTML_HANDLERS: Incomplete + +def handle_element(element, box, get_image_from_uri, base_url): ... +def handler(tag): ... +def make_replaced_box(element, box, image): ... +def handle_img(element, box, get_image_from_uri, base_url): ... +def handle_embed(element, box, get_image_from_uri, base_url): ... +def handle_object(element, box, get_image_from_uri, base_url): ... +def handle_colgroup(element, box, _get_image_from_uri, _base_url): ... +def handle_col(element, box, _get_image_from_uri, _base_url): ... +def handle_svg(element, box, get_image_from_uri, base_url): ... +def get_html_metadata(html): ... +def strip_whitespace(string): ... + +W3C_DATE_RE: Incomplete + +def parse_w3c_date(meta_name, string): ... diff --git a/stubs/weasyprint/weasyprint/images.pyi b/stubs/weasyprint/weasyprint/images.pyi new file mode 100644 index 000000000000..05df502acf9f --- /dev/null +++ b/stubs/weasyprint/weasyprint/images.pyi @@ -0,0 +1,66 @@ +from _typeshed import Incomplete + +import pydyf + +class ImageLoadingError(ValueError): ... + +class RasterImage: + id: Incomplete + mode: Incomplete + width: Incomplete + height: Incomplete + ratio: Incomplete + optimize: Incomplete + invert_colors: Incomplete + format: str + image_data: Incomplete + def __init__( + self, pillow_image, image_id, image_data, filename=None, cache=None, orientation: str = "none", options=... + ) -> None: ... + def get_intrinsic_size(self, resolution, font_size): ... + def draw(self, stream, concrete_width, concrete_height, style) -> None: ... + def cache_image_data(self, data, filename=None, slot: str = "source"): ... + def get_x_object(self, interpolate, dpi_ratio): ... + +class LazyImage(pydyf.Object): + def __init__(self, cache, key, data) -> None: ... + @property + def data(self): ... + +class LazyLocalImage(pydyf.Object): + def __init__(self, filename) -> None: ... + @property + def data(self): ... + +class SVGImage: + def __init__(self, tree, base_url, url_fetcher, context) -> None: ... + def get_intrinsic_size(self, image_resolution, font_size): ... + def draw(self, stream, concrete_width, concrete_height, _style) -> None: ... + +def get_image_from_uri( + cache, url_fetcher, options, url, forced_mime_type=None, context=None, orientation: str = "from-image" +): ... +def rotate_pillow_image(pillow_image, orientation): ... +def process_color_stops(vector_length, positions, hints, style): ... +def normalize_stop_positions(positions): ... +def gradient_average_color(colors, positions): ... + +class Gradient: + colors: Incomplete + stop_positions: Incomplete + color_hints: Incomplete + repeating: Incomplete + def __init__(self, color_stops, repeating, color_hints) -> None: ... + def get_intrinsic_size(self, image_resolution, font_size): ... + def draw(self, stream, concrete_width, concrete_height, style) -> None: ... + def layout(self, width, height, style) -> None: ... + +class LinearGradient(Gradient): + def __init__(self, color_stops, direction, repeating, color_hints) -> None: ... + def layout(self, width, height, style): ... + +class RadialGradient(Gradient): + center: Incomplete + shape: Incomplete + def __init__(self, color_stops, shape, size, center, repeating, color_hints) -> None: ... + def layout(self, width, height, style): ... diff --git a/stubs/weasyprint/weasyprint/layout/__init__.pyi b/stubs/weasyprint/weasyprint/layout/__init__.pyi new file mode 100644 index 000000000000..b746f32f6040 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/__init__.pyi @@ -0,0 +1,49 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def initialize_page_maker(context, root_box) -> None: ... +def layout_fixed_boxes(context, pages, containing_page) -> Generator[Incomplete]: ... +def layout_document(html, root_box, context, max_loops: int = 8) -> Generator[Incomplete]: ... + +class FakeList(list): + def append(self, item) -> None: ... + +class LayoutContext: + style_for: Incomplete + get_image_from_uri: Incomplete + font_config: Incomplete + counter_style: Incomplete + target_collector: Incomplete + footnotes: Incomplete + page_footnotes: Incomplete + current_page_footnotes: Incomplete + reported_footnotes: Incomplete + current_footnote_area: Incomplete + page_bottom: Incomplete + string_set: Incomplete + running_elements: Incomplete + current_page: Incomplete + forced_break: bool + broken_out_of_flow: Incomplete + in_column: bool + tables: Incomplete + dictionaries: Incomplete + def __init__(self, style_for, get_image_from_uri, font_config, counter_style, target_collector) -> None: ... + def overflows_page(self, bottom_space, position_y): ... + @staticmethod + def overflows(bottom, position_y): ... + @property + def excluded_shapes(self): ... + @excluded_shapes.setter + def excluded_shapes(self, excluded_shapes) -> None: ... + def create_block_formatting_context(self, root_box=None, new_list=None) -> None: ... + def finish_block_formatting_context(self, root_box=None) -> None: ... + def create_flex_formatting_context(self, root_box) -> None: ... + def finish_flex_formatting_context(self, root_box) -> None: ... + def add_broken_out_of_flow(self, new_box, box, containing_block, resume_at) -> None: ... + def get_string_set_for(self, page, name, keyword: str = "first"): ... + def get_running_element_for(self, page, name, keyword: str = "first"): ... + def get_string_or_element_for(self, store, page, name, keyword): ... + def layout_footnote(self, footnote): ... + def unlayout_footnote(self, footnote) -> None: ... + def report_footnote(self, footnote) -> None: ... diff --git a/stubs/weasyprint/weasyprint/layout/absolute.pyi b/stubs/weasyprint/weasyprint/layout/absolute.pyi new file mode 100644 index 000000000000..34f6a0d6c875 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/absolute.pyi @@ -0,0 +1,17 @@ +from .min_max import handle_min_max_width + +class AbsolutePlaceholder: + def __init__(self, box) -> None: ... + def set_laid_out_box(self, new_box) -> None: ... + def translate(self, dx: int = 0, dy: int = 0, ignore_floats: bool = False) -> None: ... + def copy(self): ... + def __getattr__(self, name): ... + def __setattr__(self, name, value) -> None: ... + +@handle_min_max_width +def absolute_width(box, context, cb_x, cb_y, cb_width, cb_height): ... +def absolute_height(box, context, cb_x, cb_y, cb_width, cb_height): ... +def absolute_block(context, box, containing_block, fixed_boxes, bottom_space, skip_stack, cb_x, cb_y, cb_width, cb_height): ... +def absolute_layout(context, placeholder, containing_block, fixed_boxes, bottom_space, skip_stack) -> None: ... +def absolute_box_layout(context, box, containing_block, fixed_boxes, bottom_space, skip_stack): ... +def absolute_replaced(context, box, cb_x, cb_y, cb_width, cb_height): ... diff --git a/stubs/weasyprint/weasyprint/layout/background.pyi b/stubs/weasyprint/weasyprint/layout/background.pyi new file mode 100644 index 000000000000..ae18366f3053 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/background.pyi @@ -0,0 +1,22 @@ +from _typeshed import Incomplete +from typing import NamedTuple + +class Background(NamedTuple): + color: Incomplete + layers: Incomplete + style: Incomplete + +class BackgroundLayer(NamedTuple): + image: Incomplete + size: Incomplete + position: Incomplete + repeat: Incomplete + unbounded: Incomplete + painting_area: Incomplete + positioning_area: Incomplete + clipped_boxes: Incomplete + +def box_rectangle(box, which_rectangle): ... +def layout_box_backgrounds(page, box, get_image_from_uri, layout_children: bool = True, style=None) -> None: ... +def layout_background_layer(box, page, resolution, image, size, clip, repeat, origin, position, attachment): ... +def layout_backgrounds(page, get_image_from_uri) -> None: ... diff --git a/stubs/weasyprint/weasyprint/layout/block.pyi b/stubs/weasyprint/weasyprint/layout/block.pyi new file mode 100644 index 000000000000..80bb7eedc293 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/block.pyi @@ -0,0 +1,73 @@ +from .min_max import handle_min_max_width + +def block_level_layout( + context, + box, + bottom_space, + skip_stack, + containing_block, + page_is_empty: bool = True, + absolute_boxes=None, + fixed_boxes=None, + adjoining_margins=None, + first_letter_style=None, + first_line_style=None, + discard: bool = False, + max_lines=None, +): ... +def block_level_layout_switch( + context, + box, + bottom_space, + skip_stack, + containing_block, + page_is_empty, + absolute_boxes, + fixed_boxes, + adjoining_margins, + first_letter_style, + first_line_style, + discard, + max_lines, +): ... +def block_box_layout( + context, + box, + bottom_space, + skip_stack, + containing_block, + page_is_empty, + absolute_boxes, + fixed_boxes, + adjoining_margins, + first_letter_style, + first_line_style, + discard, + max_lines, +): ... +@handle_min_max_width +def block_level_width(box, containing_block) -> None: ... +def relative_positioning(box, containing_block) -> None: ... +def block_container_layout( + context, + box, + bottom_space, + skip_stack, + page_is_empty, + absolute_boxes, + fixed_boxes, + adjoining_margins, + first_letter_style, + first_line_style, + discard, + max_lines, +): ... +def collapse_margin(adjoining_margins): ... +def block_level_page_break(sibling_before, sibling_after): ... +def block_level_page_name(sibling_before, sibling_after): ... +def find_earlier_page_break(context, children, absolute_boxes, fixed_boxes): ... +def find_last_in_flow_child(children): ... +def reversed_enumerate(seq): ... +def remove_placeholders(context, box_list, absolute_boxes, fixed_boxes) -> None: ... +def avoid_page_break(page_break, context): ... +def force_page_break(page_break, context): ... diff --git a/stubs/weasyprint/weasyprint/layout/column.pyi b/stubs/weasyprint/weasyprint/layout/column.pyi new file mode 100644 index 000000000000..848d09c38da2 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/column.pyi @@ -0,0 +1,13 @@ +def columns_layout( + context, + box, + bottom_space, + skip_stack, + containing_block, + page_is_empty, + absolute_boxes, + fixed_boxes, + adjoining_margins, + first_letter_style, + first_line_style, +): ... diff --git a/stubs/weasyprint/weasyprint/layout/flex.pyi b/stubs/weasyprint/weasyprint/layout/flex.pyi new file mode 100644 index 000000000000..bd73d04d2091 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/flex.pyi @@ -0,0 +1,5 @@ +class FlexLine(list): ... + +def flex_layout( + context, box, bottom_space, skip_stack, containing_block, page_is_empty, absolute_boxes, fixed_boxes, discard +): ... diff --git a/stubs/weasyprint/weasyprint/layout/float.pyi b/stubs/weasyprint/weasyprint/layout/float.pyi new file mode 100644 index 000000000000..00cc4c0e8fd6 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/float.pyi @@ -0,0 +1,8 @@ +from .min_max import handle_min_max_width + +@handle_min_max_width +def float_width(box, context, containing_block) -> None: ... +def float_layout(context, box, containing_block, absolute_boxes, fixed_boxes, bottom_space, skip_stack): ... +def find_float_position(context, box, containing_block): ... +def get_clearance(context, box, collapsed_margin: int = 0): ... +def avoid_collisions(context, box, containing_block, outer: bool = True): ... diff --git a/stubs/weasyprint/weasyprint/layout/grid.pyi b/stubs/weasyprint/weasyprint/layout/grid.pyi new file mode 100644 index 000000000000..ffaaeb5cbbbd --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/grid.pyi @@ -0,0 +1 @@ +def grid_layout(context, box, bottom_space, skip_stack, containing_block, page_is_empty, absolute_boxes, fixed_boxes): ... diff --git a/stubs/weasyprint/weasyprint/layout/inline.pyi b/stubs/weasyprint/weasyprint/layout/inline.pyi new file mode 100644 index 000000000000..79da8a9c49a5 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/inline.pyi @@ -0,0 +1,80 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +from .min_max import handle_min_max_width + +def iter_line_boxes( + context, + box, + position_y, + bottom_space, + skip_stack, + containing_block, + absolute_boxes, + fixed_boxes, + first_letter_style, + first_line_style, +) -> Generator[Incomplete]: ... +def get_next_linebox( + context, + linebox, + position_y, + bottom_space, + skip_stack, + containing_block, + absolute_boxes, + fixed_boxes, + first_letter_style, + first_line_style, +): ... +def skip_first_whitespace(box, skip_stack): ... +def remove_last_whitespace(context, line) -> None: ... +def first_letter_to_box(box, skip_stack, first_letter_style): ... +def atomic_box(context, box, position_x, skip_stack, containing_block, absolute_boxes, fixed_boxes): ... +def inline_block_box_layout(context, box, position_x, skip_stack, containing_block, absolute_boxes, fixed_boxes): ... +def inline_block_baseline(box): ... +@handle_min_max_width +def inline_block_width(box, context, containing_block) -> None: ... +def split_inline_level( + context, + box, + position_x, + max_x, + bottom_space, + skip_stack, + containing_block, + absolute_boxes, + fixed_boxes, + line_placeholders, + waiting_floats, + line_children, + first_letter_style, + first_line_style, +): ... +def split_inline_box( + context, + box, + position_x, + max_x, + bottom_space, + skip_stack, + containing_block, + absolute_boxes, + fixed_boxes, + line_placeholders, + waiting_floats, + line_children, + first_letter_style, + first_line_style, +): ... +def split_text_box(context, box, available_width, skip, is_line_start: bool = True): ... +def line_box_verticality(box): ... +def translate_subtree(box, dy) -> None: ... +def aligned_subtree_verticality(box, top_bottom_subtrees, baseline_y): ... +def inline_box_verticality(box, top_bottom_subtrees, baseline_y): ... +def text_align(context, line, available_width, last): ... +def justify_line(context, line, extra_width) -> None: ... +def count_expandable_spaces(box): ... +def add_word_spacing(context, box, justification_spacing, x_advance): ... +def is_phantom_linebox(linebox): ... +def can_break_inside(box): ... diff --git a/stubs/weasyprint/weasyprint/layout/leader.pyi b/stubs/weasyprint/weasyprint/layout/leader.pyi new file mode 100644 index 000000000000..d976c641a8d0 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/leader.pyi @@ -0,0 +1,2 @@ +def leader_index(box): ... +def handle_leader(context, line, containing_block) -> None: ... diff --git a/stubs/weasyprint/weasyprint/layout/min_max.pyi b/stubs/weasyprint/weasyprint/layout/min_max.pyi new file mode 100644 index 000000000000..8bba11f54c73 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/min_max.pyi @@ -0,0 +1,2 @@ +def handle_min_max_width(function): ... +def handle_min_max_height(function): ... diff --git a/stubs/weasyprint/weasyprint/layout/page.pyi b/stubs/weasyprint/weasyprint/layout/page.pyi new file mode 100644 index 000000000000..58f1e258b8a2 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/page.pyi @@ -0,0 +1,67 @@ +from _typeshed import Incomplete +from collections.abc import Generator +from typing import NamedTuple + +from .min_max import handle_min_max_height, handle_min_max_width + +class PageType(NamedTuple): + side: Incomplete + blank: Incomplete + name: Incomplete + index: Incomplete + groups: Incomplete + +class OrientedBox: + @property + def sugar(self): ... + @property + def outer(self): ... + inner: Incomplete + @outer.setter + def outer(self, new_outer_width) -> None: ... + @property + def outer_min_content_size(self): ... + @property + def outer_max_content_size(self): ... + +class VerticalBox(OrientedBox): + context: Incomplete + box: Incomplete + inner: Incomplete + margin_a: Incomplete + margin_b: Incomplete + padding_plus_border: Incomplete + def __init__(self, context, box) -> None: ... + def restore_box_attributes(self) -> None: ... + @property + def min_content_size(self): ... + @property + def max_content_size(self): ... + +class HorizontalBox(OrientedBox): + context: Incomplete + box: Incomplete + inner: Incomplete + margin_a: Incomplete + margin_b: Incomplete + padding_plus_border: Incomplete + def __init__(self, context, box) -> None: ... + def restore_box_attributes(self) -> None: ... + @property + def min_content_size(self): ... + @property + def max_content_size(self): ... + +def compute_fixed_dimension(context, box, outer, vertical, top_or_left) -> None: ... +def compute_variable_dimension(context, side_boxes, vertical, available_size) -> None: ... +def make_margin_boxes(context, page, state) -> Generator[Incomplete, None, Incomplete]: ... +def margin_box_content_layout(context, page, box): ... +def page_width_or_height(box, containing_block_size) -> None: ... +@handle_min_max_width +def page_width(box, context, containing_block_width) -> None: ... +@handle_min_max_height +def page_height(box, context, containing_block_height) -> None: ... +def make_page(context, root_box, page_type, resume_at, page_number, page_state): ... +def set_page_type_computed_styles(page_type, html, style_for) -> None: ... +def remake_page(index, context, root_box, html): ... +def make_all_pages(context, root_box, html, pages) -> Generator[Incomplete]: ... diff --git a/stubs/weasyprint/weasyprint/layout/percent.pyi b/stubs/weasyprint/weasyprint/layout/percent.pyi new file mode 100644 index 000000000000..bc30b37aee7f --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/percent.pyi @@ -0,0 +1,6 @@ +def percentage(value, computed, refer_to): ... +def resolve_one_percentage(box, property_name, refer_to) -> None: ... +def resolve_position_percentages(box, containing_block) -> None: ... +def resolve_percentages(box, containing_block) -> None: ... +def resolve_radii_percentages(box) -> None: ... +def adjust_box_sizing(box, axis) -> None: ... diff --git a/stubs/weasyprint/weasyprint/layout/preferred.pyi b/stubs/weasyprint/weasyprint/layout/preferred.pyi new file mode 100644 index 000000000000..06b5768980be --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/preferred.pyi @@ -0,0 +1,27 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def shrink_to_fit(context, box, available_content_width): ... +def min_content_width(context, box, outer: bool = True): ... +def max_content_width(context, box, outer: bool = True): ... +def min_max(box, width): ... +def margin_width(box, width, left: bool = True, right: bool = True): ... +def adjust(box, outer, width, left: bool = True, right: bool = True): ... +def block_min_content_width(context, box, outer: bool = True): ... +def block_max_content_width(context, box, outer: bool = True): ... +def inline_min_content_width( + context, box, outer: bool = True, skip_stack=None, first_line: bool = False, is_line_start: bool = False +): ... +def inline_max_content_width(context, box, outer: bool = True, is_line_start: bool = False): ... +def column_group_content_width(context, box): ... +def table_cell_min_content_width(context, box, outer): ... +def table_cell_min_max_content_width(context, box, outer: bool = True): ... +def inline_line_widths( + context, box, outer, is_line_start, minimum, skip_stack=None, first_line: bool = False +) -> Generator[Incomplete]: ... +def table_and_columns_preferred_widths(context, box, outer: bool = True): ... +def replaced_min_content_width(box, outer: bool = True): ... +def replaced_max_content_width(box, outer: bool = True): ... +def flex_min_content_width(context, box, outer: bool = True): ... +def flex_max_content_width(context, box, outer: bool = True): ... +def trailing_whitespace_size(context, box): ... diff --git a/stubs/weasyprint/weasyprint/layout/replaced.pyi b/stubs/weasyprint/weasyprint/layout/replaced.pyi new file mode 100644 index 000000000000..6b16f9a649c3 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/replaced.pyi @@ -0,0 +1,18 @@ +from .min_max import handle_min_max_height, handle_min_max_width + +def default_image_sizing( + intrinsic_width, intrinsic_height, intrinsic_ratio, specified_width, specified_height, default_width, default_height +): ... +def contain_constraint_image_sizing(constraint_width, constraint_height, intrinsic_ratio): ... +def cover_constraint_image_sizing(constraint_width, constraint_height, intrinsic_ratio): ... +def replacedbox_layout(box): ... +@handle_min_max_width +def replaced_box_width(box, containing_block) -> None: ... +@handle_min_max_height +def replaced_box_height(box) -> None: ... +def inline_replaced_box_layout(box, containing_block) -> None: ... +def inline_replaced_box_width_height(box, containing_block) -> None: ... +def min_max_auto_replaced(box) -> None: ... +def block_replaced_box_layout(context, box, containing_block): ... +@handle_min_max_width +def block_replaced_width(box, containing_block) -> None: ... diff --git a/stubs/weasyprint/weasyprint/layout/table.pyi b/stubs/weasyprint/weasyprint/layout/table.pyi new file mode 100644 index 000000000000..bfc8487322b7 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/table.pyi @@ -0,0 +1,23 @@ +from _typeshed import Incomplete + +def table_layout(context, table, bottom_space, skip_stack, containing_block, page_is_empty, absolute_boxes, fixed_boxes): ... +def add_top_padding(box, extra_padding) -> None: ... +def fixed_table_layout(box) -> None: ... +def auto_table_layout(context, box, containing_block) -> None: ... +def table_wrapper_width(context, wrapper, containing_block) -> None: ... +def cell_baseline(cell): ... +def find_in_flow_baseline(box, last: bool = False, baseline_types=...): ... +def distribute_excess_width( + context, + grid, + excess_width, + column_widths, + constrainedness, + column_intrinsic_percentages, + column_max_content_widths, + column_slice=..., +) -> None: ... + +TRANSPARENT: Incomplete + +def collapse_table_borders(table, grid_width, grid_height): ... diff --git a/stubs/weasyprint/weasyprint/logger.pyi b/stubs/weasyprint/weasyprint/logger.pyi new file mode 100644 index 000000000000..4eed6b341f6f --- /dev/null +++ b/stubs/weasyprint/weasyprint/logger.pyi @@ -0,0 +1,14 @@ +import contextlib +import logging +from _typeshed import Incomplete +from collections.abc import Generator + +LOGGER: Incomplete +PROGRESS_LOGGER: Incomplete + +class CallbackHandler(logging.Handler): + emit: Incomplete + def __init__(self, callback) -> None: ... + +@contextlib.contextmanager +def capture_logs(logger: str = "weasyprint", level=None) -> Generator[Incomplete]: ... diff --git a/stubs/weasyprint/weasyprint/matrix.pyi b/stubs/weasyprint/weasyprint/matrix.pyi new file mode 100644 index 000000000000..603ceb1a3d6b --- /dev/null +++ b/stubs/weasyprint/weasyprint/matrix.pyi @@ -0,0 +1,10 @@ +class Matrix(list): + def __init__(self, a: int = 1, b: int = 0, c: int = 0, d: int = 1, e: int = 0, f: int = 0, matrix=None) -> None: ... + def __matmul__(self, other): ... + @property + def invert(self): ... + @property + def determinant(self): ... + def transform_point(self, x, y): ... + @property + def values(self): ... diff --git a/stubs/weasyprint/weasyprint/pdf/__init__.pyi b/stubs/weasyprint/weasyprint/pdf/__init__.pyi new file mode 100644 index 000000000000..a6613c97e5f3 --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/__init__.pyi @@ -0,0 +1,5 @@ +from _typeshed import Incomplete + +VARIANTS: Incomplete + +def generate_pdf(document, target, zoom, **options): ... diff --git a/stubs/weasyprint/weasyprint/pdf/anchors.pyi b/stubs/weasyprint/weasyprint/pdf/anchors.pyi new file mode 100644 index 000000000000..76828a6f1c32 --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/anchors.pyi @@ -0,0 +1,9 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def add_links(links_and_anchors, matrix, pdf, page, names, tags) -> None: ... +def add_outlines(pdf, bookmarks, parent=None): ... +def add_forms(forms, matrix, pdf, page, resources, stream, font_map) -> None: ... +def add_annotations(links, matrix, document, pdf, page, annot_files, compress) -> None: ... +def write_pdf_attachment(pdf, attachment, compress): ... +def resolve_links(pages) -> Generator[Incomplete]: ... diff --git a/stubs/weasyprint/weasyprint/pdf/debug.pyi b/stubs/weasyprint/weasyprint/pdf/debug.pyi new file mode 100644 index 000000000000..7472ba8d9362 --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/debug.pyi @@ -0,0 +1,5 @@ +from _typeshed import Incomplete + +def debug(pdf, metadata, document, page_streams, attachments, compress) -> None: ... + +VARIANTS: Incomplete diff --git a/stubs/weasyprint/weasyprint/pdf/fonts.pyi b/stubs/weasyprint/weasyprint/pdf/fonts.pyi new file mode 100644 index 000000000000..23ddfe40ac05 --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/fonts.pyi @@ -0,0 +1,38 @@ +from _typeshed import Incomplete + +class Font: + hb_font: Incomplete + hb_face: Incomplete + file_content: Incomplete + index: Incomplete + font_size: Incomplete + style: Incomplete + family: Incomplete + variations: Incomplete + weight: Incomplete + hash: Incomplete + name: Incomplete + ascent: Incomplete + descent: Incomplete + tables: Incomplete + bitmap: bool + italic_angle: int + upem: Incomplete + png: Incomplete + svg: Incomplete + glyph_count: Incomplete + stemv: int + stemh: int + widths: Incomplete + to_unicode: Incomplete + missing: Incomplete + used_in_forms: bool + flags: Incomplete + def __init__(self, pango_font, description, font_size) -> None: ... + def get_unused_glyph_id(self, codepoint): ... + def clean(self, to_unicode, hinting) -> None: ... + @property + def type(self): ... + def subset(self, to_unicode, hinting) -> None: ... + +def build_fonts_dictionary(pdf, fonts, compress, subset, options): ... diff --git a/stubs/weasyprint/weasyprint/pdf/metadata.pyi b/stubs/weasyprint/weasyprint/pdf/metadata.pyi new file mode 100644 index 000000000000..d21b9b9cc779 --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/metadata.pyi @@ -0,0 +1,32 @@ +from _typeshed import Incomplete + +NS: Incomplete + +class DocumentMetadata: + title: Incomplete + authors: Incomplete + description: Incomplete + keywords: Incomplete + generator: Incomplete + created: Incomplete + modified: Incomplete + attachments: Incomplete + lang: Incomplete + custom: Incomplete + xmp_metadata: Incomplete + def __init__( + self, + title=None, + authors=None, + description=None, + keywords=None, + generator=None, + created=None, + modified=None, + attachments=None, + lang=None, + custom=None, + xmp_metadata=None, + ) -> None: ... + def include_in_pdf(self, pdf, variant, version, conformance, compress) -> None: ... + def generate_rdf_metadata(self, variant, version, conformance): ... diff --git a/stubs/weasyprint/weasyprint/pdf/pdfa.pyi b/stubs/weasyprint/weasyprint/pdf/pdfa.pyi new file mode 100644 index 000000000000..2aa2b86e8fbf --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/pdfa.pyi @@ -0,0 +1,5 @@ +from _typeshed import Incomplete + +def pdfa(pdf, metadata, document, page_streams, attachments, compress, version, variant) -> None: ... + +VARIANTS: Incomplete diff --git a/stubs/weasyprint/weasyprint/pdf/pdfua.pyi b/stubs/weasyprint/weasyprint/pdf/pdfua.pyi new file mode 100644 index 000000000000..d71443814530 --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/pdfua.pyi @@ -0,0 +1,5 @@ +from _typeshed import Incomplete + +def pdfua(pdf, metadata, document, page_streams, attachments, compress, version) -> None: ... + +VARIANTS: Incomplete diff --git a/stubs/weasyprint/weasyprint/pdf/pdfx.pyi b/stubs/weasyprint/weasyprint/pdf/pdfx.pyi new file mode 100644 index 000000000000..b924a5d7b7a2 --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/pdfx.pyi @@ -0,0 +1,5 @@ +from _typeshed import Incomplete + +def pdfx(pdf, metadata, document, page_streams, attachments, compress, version, variant) -> None: ... + +VARIANTS: Incomplete diff --git a/stubs/weasyprint/weasyprint/pdf/stream.pyi b/stubs/weasyprint/weasyprint/pdf/stream.pyi new file mode 100644 index 000000000000..b9364d1f1d1a --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/stream.pyi @@ -0,0 +1,41 @@ +from _typeshed import Incomplete +from collections.abc import Generator +from contextlib import contextmanager + +import pydyf + +class Stream(pydyf.Stream): + page_rectangle: Incomplete + length: Incomplete + ink_rect: Incomplete + logical_rect: Incomplete + def __init__(self, fonts, page_rectangle, resources, images, tags, color_profiles, *args, **kwargs) -> None: ... + def clone(self, **kwargs): ... + @property + def ctm(self): ... + def push_state(self) -> None: ... + def pop_state(self) -> None: ... + def transform(self, a: int = 1, b: int = 0, c: int = 0, d: int = 1, e: int = 0, f: int = 0) -> None: ... + def begin_text(self) -> None: ... + def end_text(self) -> None: ... + def set_color(self, color, stroke: bool = False) -> None: ... + def set_font_size(self, font, size) -> None: ... + def set_state(self, state) -> None: ... + def set_alpha(self, alpha, stroke: bool = False, fill=None) -> None: ... + def set_alpha_state(self, x, y, width, height, mode: str = "luminosity"): ... + def set_blend_mode(self, mode) -> None: ... + def add_font(self, pango_font): ... + def add_group(self, x, y, width, height): ... + def add_image(self, image, interpolate, ratio): ... + def add_pattern(self, x, y, width, height, repeat_width, repeat_height, matrix): ... + def add_shading(self, shading_type, color_space, domain, coords, extend, function): ... + @contextmanager + def stacked(self) -> Generator[None]: ... + @contextmanager + def marked(self, box, tag) -> Generator[None]: ... + @contextmanager + def artifact(self) -> Generator[None]: ... + @staticmethod + def create_interpolation_function(domain, c0, c1, n): ... + @staticmethod + def create_stitching_function(domain, encode, bounds, sub_functions): ... diff --git a/stubs/weasyprint/weasyprint/pdf/tags.pyi b/stubs/weasyprint/weasyprint/pdf/tags.pyi new file mode 100644 index 000000000000..bdd064432a27 --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/tags.pyi @@ -0,0 +1 @@ +def add_tags(pdf, document, page_streams) -> None: ... diff --git a/stubs/weasyprint/weasyprint/stacking.pyi b/stubs/weasyprint/weasyprint/stacking.pyi new file mode 100644 index 000000000000..79e0960f6394 --- /dev/null +++ b/stubs/weasyprint/weasyprint/stacking.pyi @@ -0,0 +1,17 @@ +from _typeshed import Incomplete + +class StackingContext: + box: Incomplete + page: Incomplete + block_level_boxes: Incomplete + float_contexts: Incomplete + negative_z_contexts: Incomplete + zero_z_contexts: Incomplete + positive_z_contexts: Incomplete + blocks_and_cells: Incomplete + z_index: Incomplete + def __init__(self, box, child_contexts, blocks, floats, blocks_and_cells, page) -> None: ... + @classmethod + def from_page(cls, page): ... + @classmethod + def from_box(cls, box, page, child_contexts=None): ... diff --git a/stubs/weasyprint/weasyprint/svg/__init__.pyi b/stubs/weasyprint/weasyprint/svg/__init__.pyi new file mode 100644 index 000000000000..97a0721b0ce8 --- /dev/null +++ b/stubs/weasyprint/weasyprint/svg/__init__.pyi @@ -0,0 +1,86 @@ +from _typeshed import Incomplete + +TAGS: Incomplete +NOT_INHERITED_ATTRIBUTES: Incomplete +COLOR_ATTRIBUTES: Incomplete +DEF_TYPES: Incomplete + +class Node: + attrib: Incomplete + vertices: Incomplete + bounding_box: Incomplete + def __init__(self, wrapper, style) -> None: ... + def copy(self): ... + def get(self, key, default=None): ... + @property + def tag(self): ... + @property + def text(self): ... + @property + def tail(self): ... + @property + def display(self): ... + @property + def visible(self): ... + def cascade(self, child) -> None: ... + def __iter__(self): ... + def get_viewbox(self): ... + def get_href(self, base_url): ... + def del_href(self) -> None: ... + @staticmethod + def process_whitespace(string, preserve): ... + def get_child(self, id_): ... + def text_children(self, element, trailing_space, text_root: bool = False): ... + def flatten(self): ... + def pop_rotation(self, original_rotate, rotate) -> None: ... + __class__: Incomplete + def override_iter(self, iterator): ... + def set_svg_size(self, svg, concrete_width, concrete_height) -> None: ... + +class LazyDefs: + def __init__(self, name, svg) -> None: ... + def __getitem__(self, name): ... + def get(self, name): ... + def __contains__(self, name) -> bool: ... + +class SVG: + tree: Incomplete + font_config: Incomplete + url_fetcher: Incomplete + url: Incomplete + filters: Incomplete + gradients: Incomplete + images: Incomplete + markers: Incomplete + masks: Incomplete + patterns: Incomplete + paths: Incomplete + symbols: Incomplete + use_cache: Incomplete + cursor_position: Incomplete + cursor_d_position: Incomplete + text_path_width: int + def __init__(self, tree, url, font_config, url_fetcher=None) -> None: ... + def get_intrinsic_size(self, font_size): ... + def get_viewbox(self): ... + def point(self, x, y, font_size): ... + def length(self, length, font_size): ... + stream: Incomplete + base_url: Incomplete + context: Incomplete + def draw(self, stream, concrete_width, concrete_height, base_url, context) -> None: ... + def draw_node(self, node, font_size, fill_stroke: bool = True) -> None: ... + def draw_markers(self, node, font_size, fill_stroke) -> None: ... + @staticmethod + def get_paint(value): ... + def set_graphical_state(self, node, font_size, text: bool = False) -> None: ... + def fill_stroke(self, node, font_size, text: bool = False) -> None: ... + def transform(self, node, font_size) -> None: ... + def inherit_element(self, element, defs) -> None: ... + def calculate_bounding_box(self, node, font_size, stroke: bool = True): ... + +class Pattern(SVG): + svg: Incomplete + tree: Incomplete + def __init__(self, tree, svg) -> None: ... + def draw_node(self, node, font_size, fill_stroke: bool = True) -> None: ... diff --git a/stubs/weasyprint/weasyprint/svg/bounding_box.pyi b/stubs/weasyprint/weasyprint/svg/bounding_box.pyi new file mode 100644 index 000000000000..8672e182c4c3 --- /dev/null +++ b/stubs/weasyprint/weasyprint/svg/bounding_box.pyi @@ -0,0 +1,18 @@ +from _typeshed import Incomplete + +EMPTY_BOUNDING_BOX: Incomplete + +def bounding_box(svg, node, font_size, stroke): ... +def bounding_box_rect(svg, node, font_size): ... +def bounding_box_circle(svg, node, font_size): ... +def bounding_box_ellipse(svg, node, font_size): ... +def bounding_box_line(svg, node, font_size): ... +def bounding_box_polyline(svg, node, font_size): ... +def bounding_box_path(svg, node, font_size): ... +def bounding_box_text(svg, node, font_size): ... +def bounding_box_g(svg, node, font_size): ... +def bounding_box_use(svg, node, font_size): ... +def extend_bounding_box(bounding_box, points): ... +def is_valid_bounding_box(bounding_box): ... + +BOUNDING_BOX_METHODS: Incomplete diff --git a/stubs/weasyprint/weasyprint/svg/css.pyi b/stubs/weasyprint/weasyprint/svg/css.pyi new file mode 100644 index 000000000000..9a77a533fd9f --- /dev/null +++ b/stubs/weasyprint/weasyprint/svg/css.pyi @@ -0,0 +1,6 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def find_stylesheets_rules(tree, stylesheet_rules, url, font_config, url_fetcher) -> Generator[Incomplete, Incomplete]: ... +def parse_declarations(input): ... +def parse_stylesheets(tree, url, font_config, url_fetcher): ... diff --git a/stubs/weasyprint/weasyprint/svg/defs.pyi b/stubs/weasyprint/weasyprint/svg/defs.pyi new file mode 100644 index 000000000000..0b76c194e9a7 --- /dev/null +++ b/stubs/weasyprint/weasyprint/svg/defs.pyi @@ -0,0 +1,10 @@ +def get_use_tree(svg, node, font_size): ... +def use(svg, node, font_size) -> None: ... +def draw_gradient_or_pattern(svg, node, name, font_size, opacity, stroke): ... +def draw_gradient(svg, node, gradient, font_size, opacity, stroke): ... +def spread_linear_gradient(spread, positions, colors, x1, y1, x2, y2, bounding_box, matrix): ... +def spread_radial_gradient(spread, positions, colors, fx, fy, fr, cx, cy, r, width, height, matrix): ... +def draw_pattern(svg, node, pattern, font_size, opacity, stroke): ... +def apply_filters(svg, node, filter_node, font_size) -> None: ... +def paint_mask(svg, node, mask, font_size) -> None: ... +def clip_path(svg, node, font_size) -> None: ... diff --git a/stubs/weasyprint/weasyprint/svg/images.pyi b/stubs/weasyprint/weasyprint/svg/images.pyi new file mode 100644 index 000000000000..a038f73dcdd0 --- /dev/null +++ b/stubs/weasyprint/weasyprint/svg/images.pyi @@ -0,0 +1,2 @@ +def svg(svg, node, font_size) -> None: ... +def image(svg, node, font_size) -> None: ... diff --git a/stubs/weasyprint/weasyprint/svg/path.pyi b/stubs/weasyprint/weasyprint/svg/path.pyi new file mode 100644 index 000000000000..9147064eb76c --- /dev/null +++ b/stubs/weasyprint/weasyprint/svg/path.pyi @@ -0,0 +1,3 @@ +PATH_LETTERS: str + +def path(svg, node, font_size) -> None: ... diff --git a/stubs/weasyprint/weasyprint/svg/shapes.pyi b/stubs/weasyprint/weasyprint/svg/shapes.pyi new file mode 100644 index 000000000000..ec8a59000fa7 --- /dev/null +++ b/stubs/weasyprint/weasyprint/svg/shapes.pyi @@ -0,0 +1,6 @@ +def circle(svg, node, font_size) -> None: ... +def ellipse(svg, node, font_size) -> None: ... +def rect(svg, node, font_size) -> None: ... +def line(svg, node, font_size) -> None: ... +def polygon(svg, node, font_size) -> None: ... +def polyline(svg, node, font_size) -> None: ... diff --git a/stubs/weasyprint/weasyprint/svg/text.pyi b/stubs/weasyprint/weasyprint/svg/text.pyi new file mode 100644 index 000000000000..5f9b56aa37b2 --- /dev/null +++ b/stubs/weasyprint/weasyprint/svg/text.pyi @@ -0,0 +1,12 @@ +from _typeshed import Incomplete + +class TextBox: + pango_layout: Incomplete + style: Incomplete + def __init__(self, pango_layout, style) -> None: ... + @property + def text(self): ... + +class Style(dict): ... + +def text(svg, node, font_size) -> None: ... diff --git a/stubs/weasyprint/weasyprint/svg/utils.pyi b/stubs/weasyprint/weasyprint/svg/utils.pyi new file mode 100644 index 000000000000..59b01dd3999d --- /dev/null +++ b/stubs/weasyprint/weasyprint/svg/utils.pyi @@ -0,0 +1,10 @@ +class PointError(Exception): ... + +def normalize(string): ... +def size(string, font_size=None, percentage_reference=None): ... +def alpha_value(value): ... +def point(svg, string, font_size): ... +def preserve_ratio(svg, node, font_size, width, height, viewbox=None): ... +def parse_url(url): ... +def color(string): ... +def transform(transform_string, transform_origin, font_size, normalized_diagonal): ... diff --git a/stubs/weasyprint/weasyprint/urls.pyi b/stubs/weasyprint/weasyprint/urls.pyi new file mode 100644 index 000000000000..9230558d25ff --- /dev/null +++ b/stubs/weasyprint/weasyprint/urls.pyi @@ -0,0 +1,72 @@ +import contextlib +from _typeshed import Incomplete +from collections.abc import Generator +from gzip import GzipFile +from urllib import request + +UNICODE_SCHEME_RE: Incomplete +BYTES_SCHEME_RE: Incomplete +FILESYSTEM_ENCODING: Incomplete +HTTP_HEADERS: Incomplete + +class StreamingGzipFile(GzipFile): + fileobj_to_close: Incomplete + def __init__(self, fileobj) -> None: ... + def close(self) -> None: ... + def seekable(self): ... + +def iri_to_uri(url): ... +def path2url(path): ... +def url_is_absolute(url): ... +def get_url_attribute(element, attr_name, base_url, allow_relative: bool = False): ... +def get_url_tuple(url, base_url): ... +def url_join(base_url, url, allow_relative, context, context_args): ... +def get_link_attribute(element, attr_name, base_url): ... +def ensure_url(string): ... +def default_url_fetcher(url, timeout: int = 10, ssl_context=None, http_headers=None, allowed_protocols=None): ... +@contextlib.contextmanager +def select_source( + guess=None, + filename=None, + url=None, + file_obj=None, + string=None, + base_url=None, + url_fetcher=None, + check_css_mime_type: bool = False, +) -> Generator[Incomplete]: ... + +class URLFetchingError(IOError): ... +class FatalURLFetchingError(BaseException): ... + +class URLFetcher(request.OpenerDirector): + def __init__( + self, + timeout: int = 10, + ssl_context=None, + http_headers=None, + allowed_protocols=None, + allow_redirects: bool = True, + fail_on_errors: bool = False, + **kwargs, + ) -> None: ... + def fetch(self, url, headers=None): ... + def open(self, url, data=None, timeout=None): ... + def __call__(self, url): ... + +class URLFetcherResponse: + url: Incomplete + status: Incomplete + headers: Incomplete + def __init__(self, url, body=None, headers=None, status: str = "200 OK", **kwargs) -> None: ... + def read(self, *args, **kwargs): ... + def close(self) -> None: ... + @property + def path(self): ... + @property + def content_type(self): ... + @property + def charset(self): ... + +@contextlib.contextmanager +def fetch(url_fetcher, url) -> Generator[Incomplete]: ... From f750a13660f832c614f14979587f11b67babcd73 Mon Sep 17 00:00:00 2001 From: TuringTux Date: Sat, 31 Jan 2026 13:43:48 +0100 Subject: [PATCH 02/56] Start adding a few type hints for HTML --- stubs/weasyprint/weasyprint/__init__.pyi | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/stubs/weasyprint/weasyprint/__init__.pyi b/stubs/weasyprint/weasyprint/__init__.pyi index 49a49a8964f4..07c9e2614a38 100644 --- a/stubs/weasyprint/weasyprint/__init__.pyi +++ b/stubs/weasyprint/weasyprint/__init__.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from pathlib import Path from .document import Document as Document, Page as Page from .urls import default_url_fetcher as default_url_fetcher @@ -18,19 +19,19 @@ class HTML: def __init__( self, guess=None, - filename=None, - url=None, + filename: str | Path | None = None, + url: str | None = None, file_obj=None, - string=None, - encoding=None, - base_url=None, + string: str | None = None, + encoding: str | None = None, + base_url: str | Path | None = None, url_fetcher=None, media_type: str = "print", ) -> None: ... - def render(self, font_config=None, counter_style=None, color_profiles=None, **options): ... + def render(self, font_config=None, counter_style=None, color_profiles=None, **options) -> Document: ... def write_pdf( self, target=None, zoom: int = 1, finisher=None, font_config=None, counter_style=None, color_profiles=None, **options - ): ... + ) -> bytes | None: ... class CSS: base_url: Incomplete From 427bbda2d135716e93891efaabb27cfb1fd73bd0 Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 11:51:42 +0200 Subject: [PATCH 03/56] Upgrade stubs to latest versions --- stubs/weasyprint/METADATA.toml | 2 +- stubs/weasyprint/weasyprint/css/__init__.pyi | 13 +++++++++---- .../weasyprint/weasyprint/css/computed_values.pyi | 8 ++++++++ stubs/weasyprint/weasyprint/css/tokens.pyi | 2 +- stubs/weasyprint/weasyprint/css/units.pyi | 6 ++++-- .../weasyprint/css/validation/expanders.pyi | 2 ++ stubs/weasyprint/weasyprint/document.pyi | 3 ++- stubs/weasyprint/weasyprint/html.pyi | 15 +++++++++++++-- stubs/weasyprint/weasyprint/layout/block.pyi | 5 +---- stubs/weasyprint/weasyprint/layout/float.pyi | 2 +- stubs/weasyprint/weasyprint/logger.pyi | 10 ---------- stubs/weasyprint/weasyprint/pdf/anchors.pyi | 2 ++ stubs/weasyprint/weasyprint/pdf/pdfa.pyi | 2 +- stubs/weasyprint/weasyprint/pdf/pdfua.pyi | 2 +- stubs/weasyprint/weasyprint/pdf/pdfx.pyi | 2 +- stubs/weasyprint/weasyprint/pdf/stream.pyi | 6 ++++-- stubs/weasyprint/weasyprint/pdf/tags.pyi | 2 +- stubs/weasyprint/weasyprint/svg/defs.pyi | 1 - stubs/weasyprint/weasyprint/svg/utils.pyi | 1 + stubs/weasyprint/weasyprint/urls.pyi | 7 ++++++- 20 files changed, 59 insertions(+), 34 deletions(-) diff --git a/stubs/weasyprint/METADATA.toml b/stubs/weasyprint/METADATA.toml index 19d025730564..a05b3fc1a2b5 100644 --- a/stubs/weasyprint/METADATA.toml +++ b/stubs/weasyprint/METADATA.toml @@ -1,2 +1,2 @@ -version = "68.0.*" +version = "69.0.*" upstream_repository = "https://github.com/Kozea/WeasyPrint" diff --git a/stubs/weasyprint/weasyprint/css/__init__.pyi b/stubs/weasyprint/weasyprint/css/__init__.pyi index 0632f5edb8ba..03649c0cb44b 100644 --- a/stubs/weasyprint/weasyprint/css/__init__.pyi +++ b/stubs/weasyprint/weasyprint/css/__init__.pyi @@ -12,6 +12,7 @@ class PageSelectorType(NamedTuple): name: Incomplete class StyleFor: + initial_page_sizes: Incomplete font_config: Incomplete def __init__(self, html, sheets, presentational_hints, font_config, target_collector) -> None: ... def __call__(self, element, pseudo_type=None): ... @@ -27,7 +28,7 @@ def find_stylesheets( ) -> Generator[Incomplete]: ... def find_style_attributes(tree, presentational_hints: bool = False, base_url=None) -> Generator[Incomplete, None, Incomplete]: ... def declaration_precedence(origin, importance): ... -def resolve_var(computed, token, parent_style, known_variables=None): ... +def resolve_var(computed, token, parent_style): ... def resolve_math(token, computed=None, property_name=None, refer_to=None): ... class InitialStyle(dict): @@ -58,16 +59,20 @@ class ComputedStyle(dict): root_style: Incomplete base_url: Incomplete font_config: Incomplete + initial_page_sizes: Incomplete cache: Incomplete - def __init__(self, parent_style, cascaded, element, pseudo_type, root_style, base_url, font_config) -> None: ... + def __init__( + self, parent_style, cascaded, element, pseudo_type, root_style, base_url, font_config, initial_page_sizes + ) -> None: ... def copy(self): ... def __missing__(self, key): ... class ColorProfile: src: Incomplete - renderingintent: Incomplete + rendering_intent: Incomplete components: Incomplete - def __init__(self, file_object, descriptors) -> None: ... + pdf_reference: Incomplete + def __init__(self, file_object, src, rendering_intent, components) -> None: ... @property def name(self): ... @property diff --git a/stubs/weasyprint/weasyprint/css/computed_values.pyi b/stubs/weasyprint/weasyprint/css/computed_values.pyi index 7a4373caabbb..3afdd63f477b 100644 --- a/stubs/weasyprint/weasyprint/css/computed_values.pyi +++ b/stubs/weasyprint/weasyprint/css/computed_values.pyi @@ -5,11 +5,19 @@ BORDER_WIDTH_KEYWORDS: Incomplete FONT_WEIGHT_RELATIVE: Incomplete PAGE_SIZES: Incomplete INITIAL_PAGE_SIZE: Incomplete +PHYSICAL_FUNCTIONS: Incomplete + +def register_logical(names, prefixes=("",), suffixes=("",)): ... +def physical_size(name, prefix, suffix, block, inline): ... +def physical_inset(name, prefix, suffix, block, inline): ... +def physical_radius(name, prefix, suffix, block, inline): ... + COMPUTER_FUNCTIONS: Incomplete def register_computer(name): ... def compute_attr(style, values): ... def background_image(style, name, values): ... +def image(style, name, image): ... def color(style, name, values): ... def compute_position(style, name, values): ... def length_or_percentage_tuple(style, name, values): ... diff --git a/stubs/weasyprint/weasyprint/css/tokens.pyi b/stubs/weasyprint/weasyprint/css/tokens.pyi index 59a6b55b3963..fae461b4ec5e 100644 --- a/stubs/weasyprint/weasyprint/css/tokens.pyi +++ b/stubs/weasyprint/weasyprint/css/tokens.pyi @@ -15,7 +15,7 @@ NAN: Incomplete class InvalidValues(ValueError): ... class PercentageInMath(ValueError): ... -class FontUnitInMath(ValueError): ... +class RelativeLengthInMath(ValueError): ... class Pending(ABC, metaclass=abc.ABCMeta): tokens: Incomplete diff --git a/stubs/weasyprint/weasyprint/css/units.pyi b/stubs/weasyprint/weasyprint/css/units.pyi index d761e2255dca..2e06491028ab 100644 --- a/stubs/weasyprint/weasyprint/css/units.pyi +++ b/stubs/weasyprint/weasyprint/css/units.pyi @@ -3,9 +3,11 @@ from _typeshed import Incomplete ANGLE_TO_RADIANS: Incomplete LENGTHS_TO_PIXELS: Incomplete RESOLUTION_TO_DPPX: Incomplete -FONT_UNITS: Incomplete ABSOLUTE_UNITS: Incomplete -LENGTH_UNITS = ABSOLUTE_UNITS | FONT_UNITS +FONT_UNITS: Incomplete +VIEWPORT_UNITS: Incomplete +RELATIVE_UNITS = FONT_UNITS | VIEWPORT_UNITS +LENGTH_UNITS = ABSOLUTE_UNITS | RELATIVE_UNITS ANGLE_UNITS: Incomplete def to_pixels(value, style, property_name, font_size=None): ... diff --git a/stubs/weasyprint/weasyprint/css/validation/expanders.pyi b/stubs/weasyprint/weasyprint/css/validation/expanders.pyi index 6e5133d3aaa4..4b063d8f2b80 100644 --- a/stubs/weasyprint/weasyprint/css/validation/expanders.pyi +++ b/stubs/weasyprint/weasyprint/css/validation/expanders.pyi @@ -12,10 +12,12 @@ class PendingExpander(Pending): def expander(property_name): ... def generic_expander(*expanded_names, **kwargs): ... +def expand_two_logical_sides(tokens, name, base_url) -> Generator[Incomplete, Incomplete]: ... def expand_four_sides(tokens, name, base_url) -> Generator[Incomplete, Incomplete]: ... def border_radius(tokens, name, base_url) -> Generator[Incomplete]: ... def expand_list_style(tokens, name, base_url) -> Generator[Incomplete]: ... def expand_border(tokens, name, base_url) -> Generator[Incomplete, Incomplete]: ... +def expand_logical_border(tokens, name, base_url) -> Generator[Incomplete, Incomplete]: ... def expand_border_side(tokens, name) -> Generator[Incomplete]: ... def expand_border_image(tokens, name, base_url) -> Generator[Incomplete]: ... def expand_mask_border(tokens, name, base_url) -> Generator[Incomplete]: ... diff --git a/stubs/weasyprint/weasyprint/document.pyi b/stubs/weasyprint/weasyprint/document.pyi index 632001eade15..31152cf8fc87 100644 --- a/stubs/weasyprint/weasyprint/document.pyi +++ b/stubs/weasyprint/weasyprint/document.pyi @@ -25,7 +25,8 @@ class Document: fonts: Incomplete font_config: Incomplete color_profiles: Incomplete - def __init__(self, pages, metadata, url_fetcher, font_config, color_profiles) -> None: ... + output_intent: Incomplete + def __init__(self, pages, metadata, url_fetcher, font_config, color_profiles, output_intent) -> None: ... def copy(self, pages: str = "all"): ... def make_bookmark_tree(self, scale: int = 1, transform_pages: bool = False): ... def write_pdf(self, target=None, zoom: int = 1, finisher=None, **options): ... diff --git a/stubs/weasyprint/weasyprint/html.pyi b/stubs/weasyprint/weasyprint/html.pyi index 1f7f93f77a4c..a983a528d91b 100644 --- a/stubs/weasyprint/weasyprint/html.pyi +++ b/stubs/weasyprint/weasyprint/html.pyi @@ -7,9 +7,20 @@ HTML5_PH: Incomplete HTML5_UA_STYLESHEET: Incomplete HTML5_UA_FORM_STYLESHEET: Incomplete HTML5_PH_STYLESHEET: Incomplete -HTML_WHITESPACE: str -HTML_SPACE_SEPARATED_TOKENS_RE: Incomplete +WHITESPACE: str +SPACE_SEPARATED_TOKENS_RE: Incomplete +INTEGER_RE: Incomplete +DIMENSION_RE: Incomplete +def parse_integer(string): ... +def parse_non_negative_integer(string): ... +def parse_dimension_value(string): ... +def parse_legacy_color(string): ... +def parse_string(string): ... +def parse_url(string): ... +def map_to_pixel_length(string): ... +def map_to_dimension_property(string): ... +def map_to_dimension_property_ignoring_zero(string): ... def ascii_lower(string): ... def element_has_link_type(element, link_type): ... diff --git a/stubs/weasyprint/weasyprint/layout/block.pyi b/stubs/weasyprint/weasyprint/layout/block.pyi index 80bb7eedc293..bd31407dcdea 100644 --- a/stubs/weasyprint/weasyprint/layout/block.pyi +++ b/stubs/weasyprint/weasyprint/layout/block.pyi @@ -1,5 +1,3 @@ -from .min_max import handle_min_max_width - def block_level_layout( context, box, @@ -45,8 +43,7 @@ def block_box_layout( discard, max_lines, ): ... -@handle_min_max_width -def block_level_width(box, containing_block) -> None: ... +def block_level_width(box, containing_block, with_min_max: bool = True) -> None: ... def relative_positioning(box, containing_block) -> None: ... def block_container_layout( context, diff --git a/stubs/weasyprint/weasyprint/layout/float.pyi b/stubs/weasyprint/weasyprint/layout/float.pyi index 00cc4c0e8fd6..d7da34650ed5 100644 --- a/stubs/weasyprint/weasyprint/layout/float.pyi +++ b/stubs/weasyprint/weasyprint/layout/float.pyi @@ -4,5 +4,5 @@ from .min_max import handle_min_max_width def float_width(box, context, containing_block) -> None: ... def float_layout(context, box, containing_block, absolute_boxes, fixed_boxes, bottom_space, skip_stack): ... def find_float_position(context, box, containing_block): ... -def get_clearance(context, box, collapsed_margin: int = 0): ... +def get_clearance(context, box, direction, collapsed_margin: int = 0): ... def avoid_collisions(context, box, containing_block, outer: bool = True): ... diff --git a/stubs/weasyprint/weasyprint/logger.pyi b/stubs/weasyprint/weasyprint/logger.pyi index 4eed6b341f6f..29097aea7d91 100644 --- a/stubs/weasyprint/weasyprint/logger.pyi +++ b/stubs/weasyprint/weasyprint/logger.pyi @@ -1,14 +1,4 @@ -import contextlib -import logging from _typeshed import Incomplete -from collections.abc import Generator LOGGER: Incomplete PROGRESS_LOGGER: Incomplete - -class CallbackHandler(logging.Handler): - emit: Incomplete - def __init__(self, callback) -> None: ... - -@contextlib.contextmanager -def capture_logs(logger: str = "weasyprint", level=None) -> Generator[Incomplete]: ... diff --git a/stubs/weasyprint/weasyprint/pdf/anchors.pyi b/stubs/weasyprint/weasyprint/pdf/anchors.pyi index 76828a6f1c32..e5c014d888ee 100644 --- a/stubs/weasyprint/weasyprint/pdf/anchors.pyi +++ b/stubs/weasyprint/weasyprint/pdf/anchors.pyi @@ -1,6 +1,8 @@ from _typeshed import Incomplete from collections.abc import Generator +MIMETYPES: Incomplete + def add_links(links_and_anchors, matrix, pdf, page, names, tags) -> None: ... def add_outlines(pdf, bookmarks, parent=None): ... def add_forms(forms, matrix, pdf, page, resources, stream, font_map) -> None: ... diff --git a/stubs/weasyprint/weasyprint/pdf/pdfa.pyi b/stubs/weasyprint/weasyprint/pdf/pdfa.pyi index 2aa2b86e8fbf..d0108cd87f44 100644 --- a/stubs/weasyprint/weasyprint/pdf/pdfa.pyi +++ b/stubs/weasyprint/weasyprint/pdf/pdfa.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -def pdfa(pdf, metadata, document, page_streams, attachments, compress, version, variant) -> None: ... +def pdfa(pdf, document, page_streams, attachments, compress, version, variant) -> None: ... VARIANTS: Incomplete diff --git a/stubs/weasyprint/weasyprint/pdf/pdfua.pyi b/stubs/weasyprint/weasyprint/pdf/pdfua.pyi index d71443814530..c55404defad9 100644 --- a/stubs/weasyprint/weasyprint/pdf/pdfua.pyi +++ b/stubs/weasyprint/weasyprint/pdf/pdfua.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -def pdfua(pdf, metadata, document, page_streams, attachments, compress, version) -> None: ... +def pdfua(pdf, document, page_streams, attachments, compress, version) -> None: ... VARIANTS: Incomplete diff --git a/stubs/weasyprint/weasyprint/pdf/pdfx.pyi b/stubs/weasyprint/weasyprint/pdf/pdfx.pyi index b924a5d7b7a2..3e001eef1cbf 100644 --- a/stubs/weasyprint/weasyprint/pdf/pdfx.pyi +++ b/stubs/weasyprint/weasyprint/pdf/pdfx.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -def pdfx(pdf, metadata, document, page_streams, attachments, compress, version, variant) -> None: ... +def pdfx(pdf, document, page_streams, attachments, compress, version, variant) -> None: ... VARIANTS: Incomplete diff --git a/stubs/weasyprint/weasyprint/pdf/stream.pyi b/stubs/weasyprint/weasyprint/pdf/stream.pyi index b9364d1f1d1a..4ad92e2c2cf3 100644 --- a/stubs/weasyprint/weasyprint/pdf/stream.pyi +++ b/stubs/weasyprint/weasyprint/pdf/stream.pyi @@ -9,7 +9,9 @@ class Stream(pydyf.Stream): length: Incomplete ink_rect: Incomplete logical_rect: Incomplete - def __init__(self, fonts, page_rectangle, resources, images, tags, color_profiles, *args, **kwargs) -> None: ... + def __init__( + self, fonts, page_rectangle, resources, images, tags, color_profiles, output_intent, *args, **kwargs + ) -> None: ... def clone(self, **kwargs): ... @property def ctm(self): ... @@ -28,7 +30,7 @@ class Stream(pydyf.Stream): def add_group(self, x, y, width, height): ... def add_image(self, image, interpolate, ratio): ... def add_pattern(self, x, y, width, height, repeat_width, repeat_height, matrix): ... - def add_shading(self, shading_type, color_space, domain, coords, extend, function): ... + def add_shading(self, shading_type, domain, coords, extend, function, color_space=None): ... @contextmanager def stacked(self) -> Generator[None]: ... @contextmanager diff --git a/stubs/weasyprint/weasyprint/pdf/tags.pyi b/stubs/weasyprint/weasyprint/pdf/tags.pyi index bdd064432a27..57f085604ad6 100644 --- a/stubs/weasyprint/weasyprint/pdf/tags.pyi +++ b/stubs/weasyprint/weasyprint/pdf/tags.pyi @@ -1 +1 @@ -def add_tags(pdf, document, page_streams) -> None: ... +def add_tags(pdf, document, pdf_version, page_streams) -> None: ... diff --git a/stubs/weasyprint/weasyprint/svg/defs.pyi b/stubs/weasyprint/weasyprint/svg/defs.pyi index 0b76c194e9a7..927da3debcb4 100644 --- a/stubs/weasyprint/weasyprint/svg/defs.pyi +++ b/stubs/weasyprint/weasyprint/svg/defs.pyi @@ -7,4 +7,3 @@ def spread_radial_gradient(spread, positions, colors, fx, fy, fr, cx, cy, r, wid def draw_pattern(svg, node, pattern, font_size, opacity, stroke): ... def apply_filters(svg, node, filter_node, font_size) -> None: ... def paint_mask(svg, node, mask, font_size) -> None: ... -def clip_path(svg, node, font_size) -> None: ... diff --git a/stubs/weasyprint/weasyprint/svg/utils.pyi b/stubs/weasyprint/weasyprint/svg/utils.pyi index 59b01dd3999d..35a15c6ecfa7 100644 --- a/stubs/weasyprint/weasyprint/svg/utils.pyi +++ b/stubs/weasyprint/weasyprint/svg/utils.pyi @@ -2,6 +2,7 @@ class PointError(Exception): ... def normalize(string): ... def size(string, font_size=None, percentage_reference=None): ... +def angle(string): ... def alpha_value(value): ... def point(svg, string, font_size): ... def preserve_ratio(svg, node, font_size, width, height, viewbox=None): ... diff --git a/stubs/weasyprint/weasyprint/urls.pyi b/stubs/weasyprint/weasyprint/urls.pyi index 9230558d25ff..bb5a8d2691d0 100644 --- a/stubs/weasyprint/weasyprint/urls.pyi +++ b/stubs/weasyprint/weasyprint/urls.pyi @@ -58,7 +58,7 @@ class URLFetcherResponse: url: Incomplete status: Incomplete headers: Incomplete - def __init__(self, url, body=None, headers=None, status: str = "200 OK", **kwargs) -> None: ... + def __init__(self, url, body=None, headers=None, status: int = 200, **kwargs) -> None: ... def read(self, *args, **kwargs): ... def close(self) -> None: ... @property @@ -67,6 +67,11 @@ class URLFetcherResponse: def content_type(self): ... @property def charset(self): ... + def geturl(self): ... + def info(self): ... + @property + def code(self): ... + def getcode(self): ... @contextlib.contextmanager def fetch(url_fetcher, url) -> Generator[Incomplete]: ... From 0842b94c4f794e1e05ba53285a5c1b0d4a59b45a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 Jul 2026 10:08:03 +0000 Subject: [PATCH 04/56] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/weasyprint/weasyprint/layout/__init__.pyi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stubs/weasyprint/weasyprint/layout/__init__.pyi b/stubs/weasyprint/weasyprint/layout/__init__.pyi index b746f32f6040..8303fe9bff61 100644 --- a/stubs/weasyprint/weasyprint/layout/__init__.pyi +++ b/stubs/weasyprint/weasyprint/layout/__init__.pyi @@ -32,10 +32,12 @@ class LayoutContext: def overflows_page(self, bottom_space, position_y): ... @staticmethod def overflows(bottom, position_y): ... + @property def excluded_shapes(self): ... @excluded_shapes.setter def excluded_shapes(self, excluded_shapes) -> None: ... + def create_block_formatting_context(self, root_box=None, new_list=None) -> None: ... def finish_block_formatting_context(self, root_box=None) -> None: ... def create_flex_formatting_context(self, root_box) -> None: ... From 46f8cc31c4fde81b372846b54a6195d97b1fb140 Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 13:15:44 +0200 Subject: [PATCH 05/56] Add further types --- stubs/weasyprint/weasyprint/__init__.pyi | 115 +++++++++++++++-------- 1 file changed, 78 insertions(+), 37 deletions(-) diff --git a/stubs/weasyprint/weasyprint/__init__.pyi b/stubs/weasyprint/weasyprint/__init__.pyi index 07c9e2614a38..783797928081 100644 --- a/stubs/weasyprint/weasyprint/__init__.pyi +++ b/stubs/weasyprint/weasyprint/__init__.pyi @@ -1,53 +1,94 @@ from _typeshed import Incomplete +from collections.abc import Callable, Mapping +from datetime import datetime from pathlib import Path +from typing import IO, Any, Literal +from .css.counters import CounterStyle from .document import Document as Document, Page as Page -from .urls import default_url_fetcher as default_url_fetcher +from .text.fonts import FontConfiguration +from .urls import URLFetcher, default_url_fetcher as default_url_fetcher __all__ = ["CSS", "DEFAULT_OPTIONS", "HTML", "VERSION", "Attachment", "Document", "Page", "__version__", "default_url_fetcher"] VERSION: str __version__: str -DEFAULT_OPTIONS: Incomplete +DEFAULT_OPTIONS: Mapping[ + Literal[ + "stylesheets", + "attachments", + "attachment_relationships", + "pdf_identifier", + "pdf_variant", + "pdf_version", + "pdf_forms", + "pdf_tags", + "uncompressed_pdf", + "xmp_metadata", + "custom_metadata", + "presentational_hints", + "output_intent", + "optimize_images", + "jpeg_quality", + "dpi", + "full_fonts", + "hinting", + "cache", + ], + None | False, +] class HTML: - base_url: Incomplete - url_fetcher: Incomplete - media_type: Incomplete + base_url: str | Path | None + url_fetcher: URLFetcher + media_type: str wrapper_element: Incomplete etree_element: Incomplete def __init__( self, - guess=None, + guess: str | Path | IO | None = None, filename: str | Path | None = None, url: str | None = None, - file_obj=None, + file_obj: IO | None = None, string: str | None = None, encoding: str | None = None, base_url: str | Path | None = None, - url_fetcher=None, + url_fetcher: URLFetcher | None = None, media_type: str = "print", ) -> None: ... - def render(self, font_config=None, counter_style=None, color_profiles=None, **options) -> Document: ... + def render( + self, + font_config: FontConfiguration | None = None, + counter_style: CounterStyle | None = None, + color_profiles=None, + **options, + ) -> Document: ... def write_pdf( - self, target=None, zoom: int = 1, finisher=None, font_config=None, counter_style=None, color_profiles=None, **options + self, + target: str | Path | IO | None = None, + zoom: float = 1, + finisher: Callable[[Document, PDF], Any] | None = None, + font_config: FontConfiguration | None = None, + counter_style: CounterStyle | None = None, + color_profiles=None, + **options, ) -> bytes | None: ... class CSS: - base_url: Incomplete + base_url: str | Path | None matcher: Incomplete page_rules: Incomplete layers: Incomplete def __init__( self, - guess=None, - filename=None, - url=None, - file_obj=None, - string=None, - encoding=None, - base_url=None, - url_fetcher=None, + guess: str | Path | IO | None = None, + filename: str | Path | None = None, + url: str | None = None, + file_obj: IO | None = None, + string: str | None = None, + encoding: str | None = None, + base_url: str | Path | None = None, + url_fetcher: URLFetcher | None = None, _check_mime_type: bool = False, media_type: str = "print", font_config=None, @@ -60,25 +101,25 @@ class CSS: ) -> None: ... class Attachment: - source: Incomplete - name: Incomplete - description: Incomplete - relationship: Incomplete - md5: Incomplete - created: Incomplete - modified: Incomplete + source: tuple[IO, str, str | None, str | None] + name: str | None + description: str | None + relationship: str + md5: None + created: datetime + modified: datetime def __init__( self, - guess=None, - filename=None, - url=None, - file_obj=None, - string=None, - base_url=None, - url_fetcher=None, - name=None, - description=None, - created=None, - modified=None, + guess: str | Path | IO | None = None, + filename: str | Path | None = None, + url: str | None = None, + file_obj: IO | None = None, + string: str | None = None, + base_url: str | Path | None = None, + url_fetcher: URLFetcher | None = None, + name: str | None = None, + description: str | None = None, + created: datetime | None = None, + modified: datetime | None = None, relationship: str = "Unspecified", ) -> None: ... From bdaab6025544f0dd4950c19c1b6ef583d181e897 Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 13:19:10 +0200 Subject: [PATCH 06/56] Mark undocumented properties as undocumented --- stubs/weasyprint/weasyprint/__init__.pyi | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/stubs/weasyprint/weasyprint/__init__.pyi b/stubs/weasyprint/weasyprint/__init__.pyi index 783797928081..c3f92c6c4a60 100644 --- a/stubs/weasyprint/weasyprint/__init__.pyi +++ b/stubs/weasyprint/weasyprint/__init__.pyi @@ -4,6 +4,9 @@ from datetime import datetime from pathlib import Path from typing import IO, Any, Literal +from csselect2 import ElementWrapper +from xml.etree.ElementTree import Element + from .css.counters import CounterStyle from .document import Document as Document, Page as Page from .text.fonts import FontConfiguration @@ -39,11 +42,11 @@ DEFAULT_OPTIONS: Mapping[ ] class HTML: - base_url: str | Path | None - url_fetcher: URLFetcher - media_type: str - wrapper_element: Incomplete - etree_element: Incomplete + base_url: str | Path | None # undocumented + url_fetcher: URLFetcher # undocumented + media_type: str # undocumented + wrapper_element: ElementWrapper # undocumented + etree_element: Element # undocumented def __init__( self, guess: str | Path | IO | None = None, From 0425f51031f204b537e3bc7266c057432958eb79 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 Jul 2026 11:21:24 +0000 Subject: [PATCH 07/56] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/weasyprint/weasyprint/__init__.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/weasyprint/weasyprint/__init__.pyi b/stubs/weasyprint/weasyprint/__init__.pyi index c3f92c6c4a60..ffa9dcab45f4 100644 --- a/stubs/weasyprint/weasyprint/__init__.pyi +++ b/stubs/weasyprint/weasyprint/__init__.pyi @@ -3,9 +3,9 @@ from collections.abc import Callable, Mapping from datetime import datetime from pathlib import Path from typing import IO, Any, Literal +from xml.etree.ElementTree import Element from csselect2 import ElementWrapper -from xml.etree.ElementTree import Element from .css.counters import CounterStyle from .document import Document as Document, Page as Page From 88e96885a2dec483662c105fb5789a5e32e021fc Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 13:24:49 +0200 Subject: [PATCH 08/56] Annotate color_profiles --- stubs/weasyprint/weasyprint/__init__.pyi | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/stubs/weasyprint/weasyprint/__init__.pyi b/stubs/weasyprint/weasyprint/__init__.pyi index ffa9dcab45f4..cd05dbad16b1 100644 --- a/stubs/weasyprint/weasyprint/__init__.pyi +++ b/stubs/weasyprint/weasyprint/__init__.pyi @@ -8,6 +8,7 @@ from xml.etree.ElementTree import Element from csselect2 import ElementWrapper from .css.counters import CounterStyle +from .css import ColorProfile from .document import Document as Document, Page as Page from .text.fonts import FontConfiguration from .urls import URLFetcher, default_url_fetcher as default_url_fetcher @@ -63,7 +64,7 @@ class HTML: self, font_config: FontConfiguration | None = None, counter_style: CounterStyle | None = None, - color_profiles=None, + color_profiles: dict[str, ColorProfile] | None=None, **options, ) -> Document: ... def write_pdf( @@ -73,7 +74,7 @@ class HTML: finisher: Callable[[Document, PDF], Any] | None = None, font_config: FontConfiguration | None = None, counter_style: CounterStyle | None = None, - color_profiles=None, + color_profiles: dict[str, ColorProfile] | None = None, **options, ) -> bytes | None: ... @@ -94,9 +95,9 @@ class CSS: url_fetcher: URLFetcher | None = None, _check_mime_type: bool = False, media_type: str = "print", - font_config=None, - counter_style=None, - color_profiles=None, + font_config: FontConfiguration | None = None, + counter_style: CounterStyle | None = None, + color_profiles: dict[str, ColorProfile] | None = None, matcher=None, page_rules=None, layers=None, From 213f4560835a8c282ef7f6e34e4859223a8418c3 Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 13:26:01 +0200 Subject: [PATCH 09/56] Fix broken toml key --- stubs/weasyprint/METADATA.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/weasyprint/METADATA.toml b/stubs/weasyprint/METADATA.toml index a05b3fc1a2b5..46146db8cc8e 100644 --- a/stubs/weasyprint/METADATA.toml +++ b/stubs/weasyprint/METADATA.toml @@ -1,2 +1,2 @@ version = "69.0.*" -upstream_repository = "https://github.com/Kozea/WeasyPrint" +upstream-repository = "https://github.com/Kozea/WeasyPrint" From 86286e92777d69e9af2e4c9bc2c1e09f8e1dcf1b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 Jul 2026 11:27:51 +0000 Subject: [PATCH 10/56] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/weasyprint/weasyprint/__init__.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/weasyprint/weasyprint/__init__.pyi b/stubs/weasyprint/weasyprint/__init__.pyi index cd05dbad16b1..bdc7c5ecac1c 100644 --- a/stubs/weasyprint/weasyprint/__init__.pyi +++ b/stubs/weasyprint/weasyprint/__init__.pyi @@ -7,8 +7,8 @@ from xml.etree.ElementTree import Element from csselect2 import ElementWrapper -from .css.counters import CounterStyle from .css import ColorProfile +from .css.counters import CounterStyle from .document import Document as Document, Page as Page from .text.fonts import FontConfiguration from .urls import URLFetcher, default_url_fetcher as default_url_fetcher @@ -64,7 +64,7 @@ class HTML: self, font_config: FontConfiguration | None = None, counter_style: CounterStyle | None = None, - color_profiles: dict[str, ColorProfile] | None=None, + color_profiles: dict[str, ColorProfile] | None = None, **options, ) -> Document: ... def write_pdf( From 931bd96fc3a62027f38cfd2de80753639913d48e Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 17:51:25 +0200 Subject: [PATCH 11/56] Add further annotations in __init__.pyi --- stubs/weasyprint/weasyprint/__init__.pyi | 107 +++++++++++++---------- 1 file changed, 61 insertions(+), 46 deletions(-) diff --git a/stubs/weasyprint/weasyprint/__init__.pyi b/stubs/weasyprint/weasyprint/__init__.pyi index bdc7c5ecac1c..a4f1fd9dcb4f 100644 --- a/stubs/weasyprint/weasyprint/__init__.pyi +++ b/stubs/weasyprint/weasyprint/__init__.pyi @@ -1,11 +1,12 @@ -from _typeshed import Incomplete -from collections.abc import Callable, Mapping +from _typeshed import Incomplete, TypeAlias +from collections.abc import Callable from datetime import datetime from pathlib import Path -from typing import IO, Any, Literal +from typing import IO, Any, TypedDict, Unpack from xml.etree.ElementTree import Element -from csselect2 import ElementWrapper +from csselect2 import ElementWrapper, Matcher +from pypdf import PDF from .css import ColorProfile from .css.counters import CounterStyle @@ -13,34 +14,48 @@ from .document import Document as Document, Page as Page from .text.fonts import FontConfiguration from .urls import URLFetcher, default_url_fetcher as default_url_fetcher -__all__ = ["CSS", "DEFAULT_OPTIONS", "HTML", "VERSION", "Attachment", "Document", "Page", "__version__", "default_url_fetcher"] +__all__ = [ + "CSS", + "DEFAULT_OPTIONS", + "HTML", + "VERSION", + "Attachment", + "Document", + "Page", + "__version__", + "default_url_fetcher", + "Options", + "PageRule", + "Selector", +] VERSION: str __version__: str -DEFAULT_OPTIONS: Mapping[ - Literal[ - "stylesheets", - "attachments", - "attachment_relationships", - "pdf_identifier", - "pdf_variant", - "pdf_version", - "pdf_forms", - "pdf_tags", - "uncompressed_pdf", - "xmp_metadata", - "custom_metadata", - "presentational_hints", - "output_intent", - "optimize_images", - "jpeg_quality", - "dpi", - "full_fonts", - "hinting", - "cache", - ], - None | False, -] +DEFAULT_OPTIONS: Options + +class Options(TypedDict): + stylesheets: Incomplete + attachments: Incomplete + attachment_relationships: Incomplete + pdf_identifier: Incomplete + pdf_variant: Incomplete + pdf_version: Incomplete + pdf_forms: Incomplete + pdf_tags: Incomplete + uncompressed_pdf: Incomplete + xmp_metadata: Incomplete + custom_metadata: Incomplete + presentational_hints: Incomplete + output_intent: Incomplete + optimize_images: Incomplete + jpeg_quality: Incomplete + dpi: Incomplete + full_fonts: Incomplete + hinting: Incomplete + cache: Incomplete + +Selector: TypeAlias = tuple[Incomplete, str | None, Incomplete] +PageRule: TypeAlias = tuple[Incomplete, list[Selector], Incomplete] class HTML: base_url: str | Path | None # undocumented @@ -65,7 +80,7 @@ class HTML: font_config: FontConfiguration | None = None, counter_style: CounterStyle | None = None, color_profiles: dict[str, ColorProfile] | None = None, - **options, + **options: Unpack[Options], ) -> Document: ... def write_pdf( self, @@ -75,14 +90,14 @@ class HTML: font_config: FontConfiguration | None = None, counter_style: CounterStyle | None = None, color_profiles: dict[str, ColorProfile] | None = None, - **options, + **options: Unpack[Options], ) -> bytes | None: ... class CSS: - base_url: str | Path | None - matcher: Incomplete - page_rules: Incomplete - layers: Incomplete + base_url: str | Path | None # undocumented + matcher: Matcher # undocumented + page_rules: list[PageRule] # undocumented + layers: Incomplete # undocumented def __init__( self, guess: str | Path | IO | None = None, @@ -98,20 +113,20 @@ class CSS: font_config: FontConfiguration | None = None, counter_style: CounterStyle | None = None, color_profiles: dict[str, ColorProfile] | None = None, - matcher=None, - page_rules=None, - layers=None, - layer=None, + matcher: Matcher | None = None, + page_rules: list[PageRule] = None, + layers: Incomplete = None, + layer: Incomplete = None, ) -> None: ... class Attachment: - source: tuple[IO, str, str | None, str | None] - name: str | None - description: str | None - relationship: str - md5: None - created: datetime - modified: datetime + source: tuple[IO, str, str | None, str | None] # undocumented + name: str | None # undocumented + description: str | None # undocumented + relationship: str # undocumented + md5: Incomplete # undocumented + created: datetime # undocumented + modified: datetime # undocumented def __init__( self, guess: str | Path | IO | None = None, From e15bfbb361dbec9d0a6f47b5df9664cac033ceed Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 17:54:57 +0200 Subject: [PATCH 12/56] Try inferring type of layer --- stubs/weasyprint/weasyprint/__init__.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/weasyprint/weasyprint/__init__.pyi b/stubs/weasyprint/weasyprint/__init__.pyi index a4f1fd9dcb4f..bd527adab4d5 100644 --- a/stubs/weasyprint/weasyprint/__init__.pyi +++ b/stubs/weasyprint/weasyprint/__init__.pyi @@ -97,7 +97,7 @@ class CSS: base_url: str | Path | None # undocumented matcher: Matcher # undocumented page_rules: list[PageRule] # undocumented - layers: Incomplete # undocumented + layers: list[str] # undocumented def __init__( self, guess: str | Path | IO | None = None, @@ -115,7 +115,7 @@ class CSS: color_profiles: dict[str, ColorProfile] | None = None, matcher: Matcher | None = None, page_rules: list[PageRule] = None, - layers: Incomplete = None, + layers: list[str] | None = None, layer: Incomplete = None, ) -> None: ... From 3da66c606ce041c25c1460e97b9cc068cd80ac96 Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 17:55:18 +0200 Subject: [PATCH 13/56] Add missing "| None" --- stubs/weasyprint/weasyprint/__init__.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/weasyprint/weasyprint/__init__.pyi b/stubs/weasyprint/weasyprint/__init__.pyi index bd527adab4d5..5f988b353fe9 100644 --- a/stubs/weasyprint/weasyprint/__init__.pyi +++ b/stubs/weasyprint/weasyprint/__init__.pyi @@ -114,7 +114,7 @@ class CSS: counter_style: CounterStyle | None = None, color_profiles: dict[str, ColorProfile] | None = None, matcher: Matcher | None = None, - page_rules: list[PageRule] = None, + page_rules: list[PageRule] | None = None, layers: list[str] | None = None, layer: Incomplete = None, ) -> None: ... From 6d3440a33891709bdb66201a0ace35dea0ea6e82 Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 17:56:21 +0200 Subject: [PATCH 14/56] Guess type to be string --- stubs/weasyprint/weasyprint/__init__.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/weasyprint/weasyprint/__init__.pyi b/stubs/weasyprint/weasyprint/__init__.pyi index 5f988b353fe9..1f937811c1a7 100644 --- a/stubs/weasyprint/weasyprint/__init__.pyi +++ b/stubs/weasyprint/weasyprint/__init__.pyi @@ -116,7 +116,7 @@ class CSS: matcher: Matcher | None = None, page_rules: list[PageRule] | None = None, layers: list[str] | None = None, - layer: Incomplete = None, + layer: str | None = None, ) -> None: ... class Attachment: From 4dfb333ffe3d427f93176aebe24bf4f616ed6bcd Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 18:06:26 +0200 Subject: [PATCH 15/56] Fix pre-commit check warnings for __init__.pyi --- stubs/weasyprint/weasyprint/__init__.pyi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stubs/weasyprint/weasyprint/__init__.pyi b/stubs/weasyprint/weasyprint/__init__.pyi index 1f937811c1a7..373f710edf82 100644 --- a/stubs/weasyprint/weasyprint/__init__.pyi +++ b/stubs/weasyprint/weasyprint/__init__.pyi @@ -1,8 +1,9 @@ -from _typeshed import Incomplete, TypeAlias +from _typeshed import Incomplete from collections.abc import Callable from datetime import datetime from pathlib import Path -from typing import IO, Any, TypedDict, Unpack +from typing import IO, Any, TypedDict +from typing_extensions import TypeAlias, Unpack from xml.etree.ElementTree import Element from csselect2 import ElementWrapper, Matcher From 190b8a627d2d7116bf5a69ea50956520fab8691d Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 18:28:27 +0200 Subject: [PATCH 16/56] Delete files which we won't need type annotations for --- stubs/weasyprint/weasyprint/anchors.pyi | 3 - .../weasyprint/css/computed_values.pyi | 55 ---- stubs/weasyprint/weasyprint/css/counters.pyi | 4 +- stubs/weasyprint/weasyprint/css/functions.pyi | 15 -- .../weasyprint/css/media_queries.pyi | 2 - .../weasyprint/weasyprint/css/properties.pyi | 13 - stubs/weasyprint/weasyprint/css/targets.pyi | 35 --- stubs/weasyprint/weasyprint/css/tokens.pyi | 55 ---- stubs/weasyprint/weasyprint/css/units.pyi | 14 - .../weasyprint/css/validation/__init__.pyi | 8 - .../weasyprint/css/validation/descriptors.pyi | 49 ---- .../weasyprint/css/validation/expanders.pyi | 47 ---- .../weasyprint/css/validation/properties.pyi | 249 ------------------ stubs/weasyprint/weasyprint/draw/__init__.pyi | 11 - stubs/weasyprint/weasyprint/draw/border.pyi | 14 - stubs/weasyprint/weasyprint/draw/color.pyi | 4 - stubs/weasyprint/weasyprint/draw/text.pyi | 4 - stubs/weasyprint/weasyprint/html.pyi | 43 --- stubs/weasyprint/weasyprint/images.pyi | 66 ----- .../weasyprint/weasyprint/layout/__init__.pyi | 51 ---- .../weasyprint/weasyprint/layout/absolute.pyi | 17 -- .../weasyprint/layout/background.pyi | 22 -- stubs/weasyprint/weasyprint/layout/block.pyi | 70 ----- stubs/weasyprint/weasyprint/layout/column.pyi | 13 - stubs/weasyprint/weasyprint/layout/flex.pyi | 5 - stubs/weasyprint/weasyprint/layout/float.pyi | 8 - stubs/weasyprint/weasyprint/layout/grid.pyi | 1 - stubs/weasyprint/weasyprint/layout/inline.pyi | 80 ------ stubs/weasyprint/weasyprint/layout/leader.pyi | 2 - .../weasyprint/weasyprint/layout/min_max.pyi | 2 - stubs/weasyprint/weasyprint/layout/page.pyi | 67 ----- .../weasyprint/weasyprint/layout/percent.pyi | 6 - .../weasyprint/layout/preferred.pyi | 27 -- .../weasyprint/weasyprint/layout/replaced.pyi | 18 -- stubs/weasyprint/weasyprint/layout/table.pyi | 23 -- stubs/weasyprint/weasyprint/logger.pyi | 4 - stubs/weasyprint/weasyprint/matrix.pyi | 10 - stubs/weasyprint/weasyprint/pdf/__init__.pyi | 5 - stubs/weasyprint/weasyprint/pdf/anchors.pyi | 11 - stubs/weasyprint/weasyprint/pdf/debug.pyi | 5 - stubs/weasyprint/weasyprint/pdf/fonts.pyi | 38 --- stubs/weasyprint/weasyprint/pdf/metadata.pyi | 32 --- stubs/weasyprint/weasyprint/pdf/pdfa.pyi | 5 - stubs/weasyprint/weasyprint/pdf/pdfua.pyi | 5 - stubs/weasyprint/weasyprint/pdf/pdfx.pyi | 5 - stubs/weasyprint/weasyprint/pdf/stream.pyi | 43 --- stubs/weasyprint/weasyprint/pdf/tags.pyi | 1 - stubs/weasyprint/weasyprint/stacking.pyi | 17 -- stubs/weasyprint/weasyprint/svg/__init__.pyi | 86 ------ .../weasyprint/svg/bounding_box.pyi | 18 -- stubs/weasyprint/weasyprint/svg/css.pyi | 6 - stubs/weasyprint/weasyprint/svg/defs.pyi | 9 - stubs/weasyprint/weasyprint/svg/images.pyi | 2 - stubs/weasyprint/weasyprint/svg/path.pyi | 3 - stubs/weasyprint/weasyprint/svg/shapes.pyi | 6 - stubs/weasyprint/weasyprint/svg/text.pyi | 12 - stubs/weasyprint/weasyprint/svg/utils.pyi | 11 - 57 files changed, 2 insertions(+), 1435 deletions(-) delete mode 100644 stubs/weasyprint/weasyprint/anchors.pyi delete mode 100644 stubs/weasyprint/weasyprint/css/computed_values.pyi delete mode 100644 stubs/weasyprint/weasyprint/css/functions.pyi delete mode 100644 stubs/weasyprint/weasyprint/css/media_queries.pyi delete mode 100644 stubs/weasyprint/weasyprint/css/properties.pyi delete mode 100644 stubs/weasyprint/weasyprint/css/targets.pyi delete mode 100644 stubs/weasyprint/weasyprint/css/tokens.pyi delete mode 100644 stubs/weasyprint/weasyprint/css/units.pyi delete mode 100644 stubs/weasyprint/weasyprint/css/validation/__init__.pyi delete mode 100644 stubs/weasyprint/weasyprint/css/validation/descriptors.pyi delete mode 100644 stubs/weasyprint/weasyprint/css/validation/expanders.pyi delete mode 100644 stubs/weasyprint/weasyprint/css/validation/properties.pyi delete mode 100644 stubs/weasyprint/weasyprint/draw/__init__.pyi delete mode 100644 stubs/weasyprint/weasyprint/draw/border.pyi delete mode 100644 stubs/weasyprint/weasyprint/draw/color.pyi delete mode 100644 stubs/weasyprint/weasyprint/draw/text.pyi delete mode 100644 stubs/weasyprint/weasyprint/html.pyi delete mode 100644 stubs/weasyprint/weasyprint/images.pyi delete mode 100644 stubs/weasyprint/weasyprint/layout/__init__.pyi delete mode 100644 stubs/weasyprint/weasyprint/layout/absolute.pyi delete mode 100644 stubs/weasyprint/weasyprint/layout/background.pyi delete mode 100644 stubs/weasyprint/weasyprint/layout/block.pyi delete mode 100644 stubs/weasyprint/weasyprint/layout/column.pyi delete mode 100644 stubs/weasyprint/weasyprint/layout/flex.pyi delete mode 100644 stubs/weasyprint/weasyprint/layout/float.pyi delete mode 100644 stubs/weasyprint/weasyprint/layout/grid.pyi delete mode 100644 stubs/weasyprint/weasyprint/layout/inline.pyi delete mode 100644 stubs/weasyprint/weasyprint/layout/leader.pyi delete mode 100644 stubs/weasyprint/weasyprint/layout/min_max.pyi delete mode 100644 stubs/weasyprint/weasyprint/layout/page.pyi delete mode 100644 stubs/weasyprint/weasyprint/layout/percent.pyi delete mode 100644 stubs/weasyprint/weasyprint/layout/preferred.pyi delete mode 100644 stubs/weasyprint/weasyprint/layout/replaced.pyi delete mode 100644 stubs/weasyprint/weasyprint/layout/table.pyi delete mode 100644 stubs/weasyprint/weasyprint/logger.pyi delete mode 100644 stubs/weasyprint/weasyprint/matrix.pyi delete mode 100644 stubs/weasyprint/weasyprint/pdf/__init__.pyi delete mode 100644 stubs/weasyprint/weasyprint/pdf/anchors.pyi delete mode 100644 stubs/weasyprint/weasyprint/pdf/debug.pyi delete mode 100644 stubs/weasyprint/weasyprint/pdf/fonts.pyi delete mode 100644 stubs/weasyprint/weasyprint/pdf/metadata.pyi delete mode 100644 stubs/weasyprint/weasyprint/pdf/pdfa.pyi delete mode 100644 stubs/weasyprint/weasyprint/pdf/pdfua.pyi delete mode 100644 stubs/weasyprint/weasyprint/pdf/pdfx.pyi delete mode 100644 stubs/weasyprint/weasyprint/pdf/stream.pyi delete mode 100644 stubs/weasyprint/weasyprint/pdf/tags.pyi delete mode 100644 stubs/weasyprint/weasyprint/stacking.pyi delete mode 100644 stubs/weasyprint/weasyprint/svg/__init__.pyi delete mode 100644 stubs/weasyprint/weasyprint/svg/bounding_box.pyi delete mode 100644 stubs/weasyprint/weasyprint/svg/css.pyi delete mode 100644 stubs/weasyprint/weasyprint/svg/defs.pyi delete mode 100644 stubs/weasyprint/weasyprint/svg/images.pyi delete mode 100644 stubs/weasyprint/weasyprint/svg/path.pyi delete mode 100644 stubs/weasyprint/weasyprint/svg/shapes.pyi delete mode 100644 stubs/weasyprint/weasyprint/svg/text.pyi delete mode 100644 stubs/weasyprint/weasyprint/svg/utils.pyi diff --git a/stubs/weasyprint/weasyprint/anchors.pyi b/stubs/weasyprint/weasyprint/anchors.pyi deleted file mode 100644 index 1ea4962b7bd4..000000000000 --- a/stubs/weasyprint/weasyprint/anchors.pyi +++ /dev/null @@ -1,3 +0,0 @@ -def rectangle_aabb(matrix, pos_x, pos_y, width, height): ... -def gather_anchors(box, anchors, links, bookmarks, forms, parent_matrix=None, parent_form=None) -> None: ... -def make_page_bookmark_tree(page, skipped_levels, last_by_depth, previous_level, page_number, matrix): ... diff --git a/stubs/weasyprint/weasyprint/css/computed_values.pyi b/stubs/weasyprint/weasyprint/css/computed_values.pyi deleted file mode 100644 index 3afdd63f477b..000000000000 --- a/stubs/weasyprint/weasyprint/css/computed_values.pyi +++ /dev/null @@ -1,55 +0,0 @@ -from _typeshed import Incomplete - -FONT_SIZE_KEYWORDS: Incomplete -BORDER_WIDTH_KEYWORDS: Incomplete -FONT_WEIGHT_RELATIVE: Incomplete -PAGE_SIZES: Incomplete -INITIAL_PAGE_SIZE: Incomplete -PHYSICAL_FUNCTIONS: Incomplete - -def register_logical(names, prefixes=("",), suffixes=("",)): ... -def physical_size(name, prefix, suffix, block, inline): ... -def physical_inset(name, prefix, suffix, block, inline): ... -def physical_radius(name, prefix, suffix, block, inline): ... - -COMPUTER_FUNCTIONS: Incomplete - -def register_computer(name): ... -def compute_attr(style, values): ... -def background_image(style, name, values): ... -def image(style, name, image): ... -def color(style, name, values): ... -def compute_position(style, name, values): ... -def length_or_percentage_tuple(style, name, values): ... -def length_tuple(style, name, values): ... -def break_before_after(style, name, value): ... -def length(style, name, value, font_size=None, pixels_only: bool = False): ... -def bleed(style, name, value): ... -def pixel_length(style, name, value): ... -def background_size(style, name, values): ... -def image_orientation(style, name, values): ... -def border_width(style, name, value): ... -def border_image_slice(style, name, values): ... -def border_image_width(style, name, values): ... -def border_image_outset(style, name, values): ... -def border_image_repeat(style, name, values): ... -def length_pixels_only(style, name, value): ... -def border_radius(style, name, values): ... -def gap(style, name, value): ... -def bookmark_label(style, name, values): ... -def string_set(style, name, values): ... -def content(style, name, values): ... -def display(style, name, value): ... -def compute_float(style, name, value): ... -def font_size(style, name, value): ... -def font_weight(style, name, value): ... -def grid_template(style, name, values): ... -def grid_auto(style, name, values): ... -def line_height(style, name, value): ... -def anchor(style, name, values): ... -def link(style, name, values): ... -def lang(style, name, values): ... -def tab_size(style, name, value): ... -def transform(style, name, value): ... -def vertical_align(style, name, value): ... -def word_spacing(style, name, value): ... diff --git a/stubs/weasyprint/weasyprint/css/counters.pyi b/stubs/weasyprint/weasyprint/css/counters.pyi index 3ce81b8ecf7d..1f875fbd05f4 100644 --- a/stubs/weasyprint/weasyprint/css/counters.pyi +++ b/stubs/weasyprint/weasyprint/css/counters.pyi @@ -1,8 +1,8 @@ -def symbol(string_or_url): ... +def symbol(string_or_url) -> str: ... def parse_counter_style_name(tokens, counter_style): ... class CounterStyle(dict): def resolve_counter(self, counter_name, previous_types=None): ... def render_value(self, counter_value, counter_name=None, counter=None, previous_types=None): ... def render_marker(self, counter_name, counter_value): ... - def copy(self): ... + def copy(self) -> CounterStyle: ... diff --git a/stubs/weasyprint/weasyprint/css/functions.pyi b/stubs/weasyprint/weasyprint/css/functions.pyi deleted file mode 100644 index 0adba4f045c7..000000000000 --- a/stubs/weasyprint/weasyprint/css/functions.pyi +++ /dev/null @@ -1,15 +0,0 @@ -from _typeshed import Incomplete - -class Function: - name: Incomplete - arguments: Incomplete - def __init__(self, token) -> None: ... - def split_space(self): ... - def split_comma(self, single_tokens: bool = True, trailing: bool = False): ... - -def check_attr(token, allowed_type=None): ... -def check_counter(token, allowed_type=None): ... -def check_content(token): ... -def check_string_or_element(string_or_element, token): ... -def check_var(token): ... -def check_math(token): ... diff --git a/stubs/weasyprint/weasyprint/css/media_queries.pyi b/stubs/weasyprint/weasyprint/css/media_queries.pyi deleted file mode 100644 index ca443734ce87..000000000000 --- a/stubs/weasyprint/weasyprint/css/media_queries.pyi +++ /dev/null @@ -1,2 +0,0 @@ -def evaluate_media_query(query_list, device_media_type): ... -def parse_media_query(tokens): ... diff --git a/stubs/weasyprint/weasyprint/css/properties.pyi b/stubs/weasyprint/weasyprint/css/properties.pyi deleted file mode 100644 index 1983a5c3405f..000000000000 --- a/stubs/weasyprint/weasyprint/css/properties.pyi +++ /dev/null @@ -1,13 +0,0 @@ -from _typeshed import Incomplete -from typing import NamedTuple - -class Dimension(NamedTuple): - value: Incomplete - unit: Incomplete - -ZERO_PIXELS: Incomplete -INITIAL_VALUES: Incomplete -KNOWN_PROPERTIES: Incomplete -INHERITED: Incomplete -TABLE_WRAPPER_BOX_PROPERTIES: Incomplete -INITIAL_NOT_COMPUTED: Incomplete diff --git a/stubs/weasyprint/weasyprint/css/targets.pyi b/stubs/weasyprint/weasyprint/css/targets.pyi deleted file mode 100644 index 94356f9a3ab2..000000000000 --- a/stubs/weasyprint/weasyprint/css/targets.pyi +++ /dev/null @@ -1,35 +0,0 @@ -from _typeshed import Incomplete - -class TargetLookupItem: - state: Incomplete - target_box: Incomplete - parse_again_functions: Incomplete - page_maker_index: Incomplete - cached_page_counter_values: Incomplete - def __init__(self, state: str = "pending") -> None: ... - -class CounterLookupItem: - parse_again: Incomplete - missing_counters: Incomplete - missing_target_counters: Incomplete - page_maker_index: Incomplete - pending: bool - cached_page_counter_values: Incomplete - def __init__(self, parse_again, missing_counters, missing_target_counters) -> None: ... - -def anchor_name_from_token(anchor_token): ... - -class TargetCollector: - target_lookup_items: Incomplete - counter_lookup_items: Incomplete - collecting: bool - had_pending_targets: bool - def __init__(self) -> None: ... - def collect_anchor(self, anchor_name) -> None: ... - def lookup_target(self, anchor_token, source_box, css_token, parse_again): ... - def store_target(self, anchor_name, target_counter_values, target_box) -> None: ... - def collect_missing_counters( - self, parent_box, css_token, parse_again_function, missing_counters, missing_target_counters - ) -> None: ... - def check_pending_targets(self) -> None: ... - def cache_target_page_counters(self, anchor_name, page_counter_values, page_maker_index, page_maker) -> None: ... diff --git a/stubs/weasyprint/weasyprint/css/tokens.pyi b/stubs/weasyprint/weasyprint/css/tokens.pyi deleted file mode 100644 index fae461b4ec5e..000000000000 --- a/stubs/weasyprint/weasyprint/css/tokens.pyi +++ /dev/null @@ -1,55 +0,0 @@ -import abc -from _typeshed import Incomplete -from abc import ABC, abstractmethod - -ZERO_PERCENT: Incomplete -FIFTY_PERCENT: Incomplete -HUNDRED_PERCENT: Incomplete -BACKGROUND_POSITION_PERCENTAGES: Incomplete -DIRECTION_KEYWORDS: Incomplete -E: Incomplete -PI: Incomplete -PLUS_INFINITY: Incomplete -MINUS_INFINITY: Incomplete -NAN: Incomplete - -class InvalidValues(ValueError): ... -class PercentageInMath(ValueError): ... -class RelativeLengthInMath(ValueError): ... - -class Pending(ABC, metaclass=abc.ABCMeta): - tokens: Incomplete - name: Incomplete - def __init__(self, tokens, name) -> None: ... - @abstractmethod - def validate(self, tokens, wanted_key): ... - def solve(self, tokens, wanted_key): ... - -def parse_color_hint(tokens): ... -def parse_color_stop(tokens): ... -def parse_color_stops_and_hints(color_stops_hints): ... -def parse_linear_gradient_parameters(arguments): ... -def parse_2d_position(tokens): ... -def parse_position(tokens): ... -def parse_radial_gradient_parameters(arguments): ... -def split_on_comma(tokens): ... -def remove_whitespace(tokens): ... -def get_keyword(token): ... -def get_custom_ident(token): ... -def get_single_keyword(tokens): ... -def get_number(token, negative: bool = True, integer: bool = False): ... -def get_string(token): ... -def get_percentage(token, negative: bool = True): ... -def get_length(token, negative: bool = True, percentage: bool = False): ... -def get_angle(token): ... -def get_resolution(token): ... -def get_image(token, base_url): ... -def get_url(token, base_url): ... -def get_quote(token): ... -def get_target(token, base_url): ... -def get_content_list(tokens, base_url): ... -def get_content_list_token(token, base_url): ... -def single_keyword(function): ... -def single_token(function): ... -def comma_separated_list(function): ... -def tokenize(item, function=None, unit=None): ... diff --git a/stubs/weasyprint/weasyprint/css/units.pyi b/stubs/weasyprint/weasyprint/css/units.pyi deleted file mode 100644 index 2e06491028ab..000000000000 --- a/stubs/weasyprint/weasyprint/css/units.pyi +++ /dev/null @@ -1,14 +0,0 @@ -from _typeshed import Incomplete - -ANGLE_TO_RADIANS: Incomplete -LENGTHS_TO_PIXELS: Incomplete -RESOLUTION_TO_DPPX: Incomplete -ABSOLUTE_UNITS: Incomplete -FONT_UNITS: Incomplete -VIEWPORT_UNITS: Incomplete -RELATIVE_UNITS = FONT_UNITS | VIEWPORT_UNITS -LENGTH_UNITS = ABSOLUTE_UNITS | RELATIVE_UNITS -ANGLE_UNITS: Incomplete - -def to_pixels(value, style, property_name, font_size=None): ... -def to_radians(value): ... diff --git a/stubs/weasyprint/weasyprint/css/validation/__init__.pyi b/stubs/weasyprint/weasyprint/css/validation/__init__.pyi deleted file mode 100644 index a67563c1b071..000000000000 --- a/stubs/weasyprint/weasyprint/css/validation/__init__.pyi +++ /dev/null @@ -1,8 +0,0 @@ -from _typeshed import Incomplete -from collections.abc import Generator - -NOT_PRINT_MEDIA: Incomplete -NESTING_SELECTOR: Incomplete -ROOT_TOKEN: Incomplete - -def preprocess_declarations(base_url, declarations, prelude=None) -> Generator[Incomplete, Incomplete]: ... diff --git a/stubs/weasyprint/weasyprint/css/validation/descriptors.pyi b/stubs/weasyprint/weasyprint/css/validation/descriptors.pyi deleted file mode 100644 index 43d34c46c0ea..000000000000 --- a/stubs/weasyprint/weasyprint/css/validation/descriptors.pyi +++ /dev/null @@ -1,49 +0,0 @@ -from _typeshed import Incomplete -from collections.abc import Generator - -from ..tokens import comma_separated_list, single_keyword, single_token - -DESCRIPTORS: Incomplete -NOT_PRINT_MEDIA: Incomplete - -class NoneFakeToken: - type: str - lower_value: str - -class NormalFakeToken: - type: str - lower_value: str - -def preprocess_descriptors(rule, base_url, descriptors) -> Generator[Incomplete]: ... -def descriptor(rule, descriptor_name=None, wants_base_url: bool = False): ... -def expand_font_variant(tokens) -> Generator[Incomplete]: ... -def font_family(tokens, allow_spaces: bool = False): ... -@comma_separated_list -def src(tokens, base_url): ... -@single_keyword -def font_style(keyword): ... -@single_token -def font_weight(token): ... -@single_keyword -def font_stretch(keyword): ... -def font_feature_settings(tokens): ... -def font_variant(tokens): ... -@comma_separated_list -@single_token -def unicode_range(token): ... -def system(tokens): ... -def negative(tokens, base_url): ... -def prefix_suffix(tokens, base_url): ... -@comma_separated_list -def range(tokens): ... -def pad(tokens, base_url): ... -@single_token -def fallback(token): ... -def symbols(tokens, base_url): ... -def additive_symbols(tokens, base_url): ... -@single_token -def color_profile_src(token, base_url): ... -@single_keyword -def rendering_intent(keyword): ... -@comma_separated_list -def components(tokens): ... diff --git a/stubs/weasyprint/weasyprint/css/validation/expanders.pyi b/stubs/weasyprint/weasyprint/css/validation/expanders.pyi deleted file mode 100644 index 4b063d8f2b80..000000000000 --- a/stubs/weasyprint/weasyprint/css/validation/expanders.pyi +++ /dev/null @@ -1,47 +0,0 @@ -from _typeshed import Incomplete -from collections.abc import Generator - -from ..tokens import Pending - -EXPANDERS: Incomplete - -class PendingExpander(Pending): - validator: Incomplete - def __init__(self, tokens, validator) -> None: ... - def validate(self, tokens, wanted_key): ... - -def expander(property_name): ... -def generic_expander(*expanded_names, **kwargs): ... -def expand_two_logical_sides(tokens, name, base_url) -> Generator[Incomplete, Incomplete]: ... -def expand_four_sides(tokens, name, base_url) -> Generator[Incomplete, Incomplete]: ... -def border_radius(tokens, name, base_url) -> Generator[Incomplete]: ... -def expand_list_style(tokens, name, base_url) -> Generator[Incomplete]: ... -def expand_border(tokens, name, base_url) -> Generator[Incomplete, Incomplete]: ... -def expand_logical_border(tokens, name, base_url) -> Generator[Incomplete, Incomplete]: ... -def expand_border_side(tokens, name) -> Generator[Incomplete]: ... -def expand_border_image(tokens, name, base_url) -> Generator[Incomplete]: ... -def expand_mask_border(tokens, name, base_url) -> Generator[Incomplete]: ... -def expand_background(tokens, name, base_url) -> Generator[Incomplete, Incomplete, Incomplete]: ... -def expand_text_decoration(tokens, name) -> Generator[Incomplete]: ... -def expand_page_break_before_after(tokens, name) -> Generator[Incomplete]: ... -def expand_page_break_after(tokens, name): ... -def expand_page_break_before(tokens, name): ... -def expand_page_break_inside(tokens, name) -> Generator[Incomplete]: ... -def expand_columns(tokens, name) -> Generator[Incomplete]: ... -def font_variant(tokens, name): ... -def expand_font(tokens, name) -> Generator[Incomplete]: ... -def expand_word_wrap(tokens, name) -> Generator[Incomplete]: ... -def expand_flex(tokens, name) -> Generator[Incomplete]: ... -def expand_flex_flow(tokens, name) -> Generator[Incomplete]: ... -def expand_grid_template(tokens, name) -> Generator[Incomplete, Incomplete]: ... -def expand_grid(tokens, name) -> Generator[Incomplete]: ... -def expand_grid_column_row(tokens, name) -> Generator[Incomplete]: ... -def expand_grid_area(tokens, name) -> Generator[Incomplete]: ... -def expand_gap(tokens, name) -> Generator[Incomplete]: ... -def expand_legacy_column_gap(tokens, name) -> Generator[Incomplete]: ... -def expand_legacy_row_gap(tokens, name) -> Generator[Incomplete]: ... -def expand_place_content(tokens, name) -> None: ... -def expand_place_items(tokens, name) -> None: ... -def expand_place_self(tokens, name) -> None: ... -def expand_line_clamp(tokens, name) -> Generator[Incomplete]: ... -def expand_text_align(tokens, name) -> Generator[Incomplete]: ... diff --git a/stubs/weasyprint/weasyprint/css/validation/properties.pyi b/stubs/weasyprint/weasyprint/css/validation/properties.pyi deleted file mode 100644 index beabb5cd6d5d..000000000000 --- a/stubs/weasyprint/weasyprint/css/validation/properties.pyi +++ /dev/null @@ -1,249 +0,0 @@ -from _typeshed import Incomplete - -from ..tokens import Pending, comma_separated_list, single_keyword, single_token - -PREFIX: str -PROPRIETARY: Incomplete -UNSTABLE: Incomplete -PROPERTIES: Incomplete - -class PendingProperty(Pending): - def validate(self, tokens, wanted_key): ... - -def property(property_name=None, proprietary: bool = False, unstable: bool = False, wants_base_url: bool = False): ... -def validate_non_shorthand(tokens, name, base_url=None, required: bool = False): ... -@comma_separated_list -@single_keyword -def background_attachment(keyword): ... -@single_token -def other_colors(token): ... -@single_token -def outline_color(token): ... -@single_keyword -def border_collapse(keyword): ... -@single_keyword -def empty_cells(keyword): ... -@single_token -def color(token): ... -@comma_separated_list -@single_token -def background_image(token, base_url): ... -@single_token -def list_style_image(token, base_url): ... -def transform_origin(tokens): ... -@comma_separated_list -def background_position(tokens): ... -@comma_separated_list -def object_position(tokens): ... -@comma_separated_list -def background_repeat(tokens): ... -@comma_separated_list -def background_size(tokens): ... -@comma_separated_list -@single_keyword -def box(keyword): ... -def border_spacing(tokens): ... -def border_corner_radius(tokens): ... -@single_keyword -def border_style(keyword): ... -@single_keyword -def break_before_after(keyword): ... -@single_keyword -def break_inside(keyword): ... -@single_keyword -def box_decoration_break(keyword): ... -@single_token -def block_ellipsis(token): ... -@single_keyword -def continue_(keyword): ... -@single_token -def max_lines(token): ... -@single_keyword -def margin_break(keyword): ... -@single_token -def page(token): ... -@single_token -def bleed(token): ... -def marks(tokens): ... -@single_keyword -def outline_style(keyword): ... -@single_token -def border_width(token): ... -@single_token -def border_image_source(token, base_url): ... -def border_image_slice(tokens): ... -def border_image_width(tokens): ... -def border_image_outset(tokens): ... -def border_image_repeat(tokens): ... -@single_keyword -def mask_border_mode(keyword): ... -@single_token -def column_width(token): ... -@single_keyword -def column_span(keyword): ... -@single_keyword -def box_sizing(keyword): ... -@single_keyword -def caption_side(keyword): ... -@single_keyword -def clear(keyword): ... -@single_token -def clip(token): ... -def content(tokens, base_url): ... -def counter_increment(tokens): ... -def counter_reset(tokens): ... -def counter_set(tokens): ... -def counter(tokens, default_integer): ... -@single_token -def lenght_precentage_or_auto(token): ... -@single_token -def width_height(token): ... -@single_token -def gap(token): ... -@single_keyword -def column_fill(keyword): ... -@single_keyword -def direction(keyword): ... -def display(tokens): ... -@single_keyword -def float_(keyword): ... -@comma_separated_list -def font_family(tokens): ... -@single_keyword -def font_kerning(keyword): ... -@single_token -def font_language_override(token): ... -def font_variant_ligatures(tokens): ... -@single_keyword -def font_variant_position(keyword): ... -@single_keyword -def font_variant_caps(keyword): ... -def font_variant_numeric(tokens): ... -def font_feature_settings(tokens): ... -@single_keyword -def font_variant_alternates(keyword): ... -def font_variant_east_asian(tokens): ... -def font_variation_settings(tokens): ... -@single_token -def font_size(token): ... -@single_keyword -def font_style(keyword): ... -@single_keyword -def font_stretch(keyword): ... -@single_token -def font_weight(token): ... -@single_keyword -def object_fit(keyword): ... -@single_token -def image_resolution(token): ... -@single_token -def spacing(token): ... -@single_token -def outline_offset(token): ... -@single_token -def line_height(token): ... -@single_keyword -def list_style_position(keyword): ... -@single_token -def list_style_type(token): ... -@single_token -def min_width_height(token): ... -@single_token -def length_or_precentage(token): ... -@single_token -def max_width_height(token): ... -@single_token -def opacity(token): ... -@single_token -def z_index(token): ... -@single_token -def orphans_widows(token): ... -@single_token -def column_count(token): ... -@single_keyword -def overflow(keyword): ... -@single_keyword -def text_overflow(keyword): ... -@single_token -def position(token): ... -def quotes(tokens): ... -@single_keyword -def table_layout(keyword): ... -@single_keyword -def text_align_all(keyword): ... -@single_keyword -def text_align_last(keyword): ... -def text_decoration_line(tokens): ... -@single_keyword -def text_decoration_style(keyword): ... -@single_token -def text_decoration_thickness(token): ... -@single_token -def text_indent(token): ... -@single_keyword -def text_transform(keyword): ... -@single_token -def vertical_align(token): ... -@single_keyword -def visibility(keyword): ... -@single_keyword -def white_space(keyword): ... -@single_keyword -def overflow_wrap(keyword): ... -@single_keyword -def word_break(keyword): ... -@single_token -def flex_basis(token): ... -@single_keyword -def flex_direction(keyword): ... -@single_token -def flex_grow_shrink(token): ... -def grid_auto(tokens): ... -def grid_auto_flow(tokens): ... -def grid_template(tokens): ... -def grid_template_areas(tokens): ... -def grid_line(tokens): ... -@single_keyword -def flex_wrap(keyword): ... -def justify_content(tokens): ... -def justify_items(tokens): ... -def justify_self(tokens): ... -def align_items(tokens): ... -def align_self(tokens): ... -def align_content(tokens): ... -@single_token -def order(token): ... -@single_keyword -def image_rendering(keyword): ... -def image_orientation(tokens): ... -def size(tokens): ... -@single_token -def anchor(token): ... -@single_token -def link(token, base_url): ... -@single_token -def tab_size(token): ... -@single_token -def hyphens(token): ... -@single_token -def hyphenate_character(token): ... -@single_token -def hyphenate_limit_zone(token): ... -def hyphenate_limit_chars(tokens): ... -@single_token -def lang(token): ... -def bookmark_label(tokens, base_url): ... -@single_token -def bookmark_level(token): ... -@single_keyword -def bookmark_state(keyword): ... -@single_keyword -def footnote_display(keyword): ... -@single_keyword -def footnote_policy(keyword): ... -@comma_separated_list -def string_set(tokens, base_url): ... -def transform(tokens): ... -@single_token -def appearance(token): ... -def color_scheme(tokens): ... diff --git a/stubs/weasyprint/weasyprint/draw/__init__.pyi b/stubs/weasyprint/weasyprint/draw/__init__.pyi deleted file mode 100644 index 4e1f46756edd..000000000000 --- a/stubs/weasyprint/weasyprint/draw/__init__.pyi +++ /dev/null @@ -1,11 +0,0 @@ -def draw_page(page, stream) -> None: ... -def draw_stacking_context(stream, stacking_context) -> None: ... -def draw_background(stream, bg, clip_box: bool = True, bleed=None, marks=()) -> None: ... -def draw_background_image(stream, layer, style) -> None: ... -def draw_table(stream, table): ... -def draw_collapsed_borders(stream, table): ... -def draw_replacedbox(stream, box) -> None: ... -def draw_inline_level( - stream, page, box, offset_x: int = 0, text_overflow: str = "clip", block_ellipsis: str = "none" -) -> None: ... -def draw_block_level(page, stream, blocks_and_cells) -> None: ... diff --git a/stubs/weasyprint/weasyprint/draw/border.pyi b/stubs/weasyprint/weasyprint/draw/border.pyi deleted file mode 100644 index 4a91f968fb50..000000000000 --- a/stubs/weasyprint/weasyprint/draw/border.pyi +++ /dev/null @@ -1,14 +0,0 @@ -from _typeshed import Incomplete - -SIDES: Incomplete - -def set_mask_border(stream, box) -> None: ... -def draw_column_rules(stream, box) -> None: ... -def draw_border(stream, box) -> None: ... -def draw_border_image(box, stream, image, border_slice, border_repeat, border_outset, border_width): ... -def clip_border_segment(stream, style, width, side, border_box, border_widths=None, radii=None): ... -def draw_rounded_border(stream, box, style, color) -> None: ... -def draw_rect_border(stream, box, widths, style, color) -> None: ... -def draw_line(stream, x1, y1, x2, y2, thickness, style, color, offset: int = 0) -> None: ... -def draw_outline(stream, box) -> None: ... -def rounded_box(stream, radii) -> None: ... diff --git a/stubs/weasyprint/weasyprint/draw/color.pyi b/stubs/weasyprint/weasyprint/draw/color.pyi deleted file mode 100644 index eafb78956314..000000000000 --- a/stubs/weasyprint/weasyprint/draw/color.pyi +++ /dev/null @@ -1,4 +0,0 @@ -def get_color(style, key): ... -def darken(color): ... -def lighten(color): ... -def styled_color(style, color, side): ... diff --git a/stubs/weasyprint/weasyprint/draw/text.pyi b/stubs/weasyprint/weasyprint/draw/text.pyi deleted file mode 100644 index 3137e41b372f..000000000000 --- a/stubs/weasyprint/weasyprint/draw/text.pyi +++ /dev/null @@ -1,4 +0,0 @@ -def draw_text(stream, textbox, offset_x, text_overflow, block_ellipsis) -> None: ... -def draw_emojis(stream, style, x, y, emojis) -> None: ... -def draw_first_line(stream, textbox, text_overflow, block_ellipsis, matrix): ... -def draw_text_decoration(stream, textbox, offset_x, offset_y, thickness, color) -> None: ... diff --git a/stubs/weasyprint/weasyprint/html.pyi b/stubs/weasyprint/weasyprint/html.pyi deleted file mode 100644 index a983a528d91b..000000000000 --- a/stubs/weasyprint/weasyprint/html.pyi +++ /dev/null @@ -1,43 +0,0 @@ -from _typeshed import Incomplete - -HTML5_UA_COUNTER_STYLE: Incomplete -HTML5_UA: Incomplete -HTML5_UA_FORM: Incomplete -HTML5_PH: Incomplete -HTML5_UA_STYLESHEET: Incomplete -HTML5_UA_FORM_STYLESHEET: Incomplete -HTML5_PH_STYLESHEET: Incomplete -WHITESPACE: str -SPACE_SEPARATED_TOKENS_RE: Incomplete -INTEGER_RE: Incomplete -DIMENSION_RE: Incomplete - -def parse_integer(string): ... -def parse_non_negative_integer(string): ... -def parse_dimension_value(string): ... -def parse_legacy_color(string): ... -def parse_string(string): ... -def parse_url(string): ... -def map_to_pixel_length(string): ... -def map_to_dimension_property(string): ... -def map_to_dimension_property_ignoring_zero(string): ... -def ascii_lower(string): ... -def element_has_link_type(element, link_type): ... - -HTML_HANDLERS: Incomplete - -def handle_element(element, box, get_image_from_uri, base_url): ... -def handler(tag): ... -def make_replaced_box(element, box, image): ... -def handle_img(element, box, get_image_from_uri, base_url): ... -def handle_embed(element, box, get_image_from_uri, base_url): ... -def handle_object(element, box, get_image_from_uri, base_url): ... -def handle_colgroup(element, box, _get_image_from_uri, _base_url): ... -def handle_col(element, box, _get_image_from_uri, _base_url): ... -def handle_svg(element, box, get_image_from_uri, base_url): ... -def get_html_metadata(html): ... -def strip_whitespace(string): ... - -W3C_DATE_RE: Incomplete - -def parse_w3c_date(meta_name, string): ... diff --git a/stubs/weasyprint/weasyprint/images.pyi b/stubs/weasyprint/weasyprint/images.pyi deleted file mode 100644 index 05df502acf9f..000000000000 --- a/stubs/weasyprint/weasyprint/images.pyi +++ /dev/null @@ -1,66 +0,0 @@ -from _typeshed import Incomplete - -import pydyf - -class ImageLoadingError(ValueError): ... - -class RasterImage: - id: Incomplete - mode: Incomplete - width: Incomplete - height: Incomplete - ratio: Incomplete - optimize: Incomplete - invert_colors: Incomplete - format: str - image_data: Incomplete - def __init__( - self, pillow_image, image_id, image_data, filename=None, cache=None, orientation: str = "none", options=... - ) -> None: ... - def get_intrinsic_size(self, resolution, font_size): ... - def draw(self, stream, concrete_width, concrete_height, style) -> None: ... - def cache_image_data(self, data, filename=None, slot: str = "source"): ... - def get_x_object(self, interpolate, dpi_ratio): ... - -class LazyImage(pydyf.Object): - def __init__(self, cache, key, data) -> None: ... - @property - def data(self): ... - -class LazyLocalImage(pydyf.Object): - def __init__(self, filename) -> None: ... - @property - def data(self): ... - -class SVGImage: - def __init__(self, tree, base_url, url_fetcher, context) -> None: ... - def get_intrinsic_size(self, image_resolution, font_size): ... - def draw(self, stream, concrete_width, concrete_height, _style) -> None: ... - -def get_image_from_uri( - cache, url_fetcher, options, url, forced_mime_type=None, context=None, orientation: str = "from-image" -): ... -def rotate_pillow_image(pillow_image, orientation): ... -def process_color_stops(vector_length, positions, hints, style): ... -def normalize_stop_positions(positions): ... -def gradient_average_color(colors, positions): ... - -class Gradient: - colors: Incomplete - stop_positions: Incomplete - color_hints: Incomplete - repeating: Incomplete - def __init__(self, color_stops, repeating, color_hints) -> None: ... - def get_intrinsic_size(self, image_resolution, font_size): ... - def draw(self, stream, concrete_width, concrete_height, style) -> None: ... - def layout(self, width, height, style) -> None: ... - -class LinearGradient(Gradient): - def __init__(self, color_stops, direction, repeating, color_hints) -> None: ... - def layout(self, width, height, style): ... - -class RadialGradient(Gradient): - center: Incomplete - shape: Incomplete - def __init__(self, color_stops, shape, size, center, repeating, color_hints) -> None: ... - def layout(self, width, height, style): ... diff --git a/stubs/weasyprint/weasyprint/layout/__init__.pyi b/stubs/weasyprint/weasyprint/layout/__init__.pyi deleted file mode 100644 index 8303fe9bff61..000000000000 --- a/stubs/weasyprint/weasyprint/layout/__init__.pyi +++ /dev/null @@ -1,51 +0,0 @@ -from _typeshed import Incomplete -from collections.abc import Generator - -def initialize_page_maker(context, root_box) -> None: ... -def layout_fixed_boxes(context, pages, containing_page) -> Generator[Incomplete]: ... -def layout_document(html, root_box, context, max_loops: int = 8) -> Generator[Incomplete]: ... - -class FakeList(list): - def append(self, item) -> None: ... - -class LayoutContext: - style_for: Incomplete - get_image_from_uri: Incomplete - font_config: Incomplete - counter_style: Incomplete - target_collector: Incomplete - footnotes: Incomplete - page_footnotes: Incomplete - current_page_footnotes: Incomplete - reported_footnotes: Incomplete - current_footnote_area: Incomplete - page_bottom: Incomplete - string_set: Incomplete - running_elements: Incomplete - current_page: Incomplete - forced_break: bool - broken_out_of_flow: Incomplete - in_column: bool - tables: Incomplete - dictionaries: Incomplete - def __init__(self, style_for, get_image_from_uri, font_config, counter_style, target_collector) -> None: ... - def overflows_page(self, bottom_space, position_y): ... - @staticmethod - def overflows(bottom, position_y): ... - - @property - def excluded_shapes(self): ... - @excluded_shapes.setter - def excluded_shapes(self, excluded_shapes) -> None: ... - - def create_block_formatting_context(self, root_box=None, new_list=None) -> None: ... - def finish_block_formatting_context(self, root_box=None) -> None: ... - def create_flex_formatting_context(self, root_box) -> None: ... - def finish_flex_formatting_context(self, root_box) -> None: ... - def add_broken_out_of_flow(self, new_box, box, containing_block, resume_at) -> None: ... - def get_string_set_for(self, page, name, keyword: str = "first"): ... - def get_running_element_for(self, page, name, keyword: str = "first"): ... - def get_string_or_element_for(self, store, page, name, keyword): ... - def layout_footnote(self, footnote): ... - def unlayout_footnote(self, footnote) -> None: ... - def report_footnote(self, footnote) -> None: ... diff --git a/stubs/weasyprint/weasyprint/layout/absolute.pyi b/stubs/weasyprint/weasyprint/layout/absolute.pyi deleted file mode 100644 index 34f6a0d6c875..000000000000 --- a/stubs/weasyprint/weasyprint/layout/absolute.pyi +++ /dev/null @@ -1,17 +0,0 @@ -from .min_max import handle_min_max_width - -class AbsolutePlaceholder: - def __init__(self, box) -> None: ... - def set_laid_out_box(self, new_box) -> None: ... - def translate(self, dx: int = 0, dy: int = 0, ignore_floats: bool = False) -> None: ... - def copy(self): ... - def __getattr__(self, name): ... - def __setattr__(self, name, value) -> None: ... - -@handle_min_max_width -def absolute_width(box, context, cb_x, cb_y, cb_width, cb_height): ... -def absolute_height(box, context, cb_x, cb_y, cb_width, cb_height): ... -def absolute_block(context, box, containing_block, fixed_boxes, bottom_space, skip_stack, cb_x, cb_y, cb_width, cb_height): ... -def absolute_layout(context, placeholder, containing_block, fixed_boxes, bottom_space, skip_stack) -> None: ... -def absolute_box_layout(context, box, containing_block, fixed_boxes, bottom_space, skip_stack): ... -def absolute_replaced(context, box, cb_x, cb_y, cb_width, cb_height): ... diff --git a/stubs/weasyprint/weasyprint/layout/background.pyi b/stubs/weasyprint/weasyprint/layout/background.pyi deleted file mode 100644 index ae18366f3053..000000000000 --- a/stubs/weasyprint/weasyprint/layout/background.pyi +++ /dev/null @@ -1,22 +0,0 @@ -from _typeshed import Incomplete -from typing import NamedTuple - -class Background(NamedTuple): - color: Incomplete - layers: Incomplete - style: Incomplete - -class BackgroundLayer(NamedTuple): - image: Incomplete - size: Incomplete - position: Incomplete - repeat: Incomplete - unbounded: Incomplete - painting_area: Incomplete - positioning_area: Incomplete - clipped_boxes: Incomplete - -def box_rectangle(box, which_rectangle): ... -def layout_box_backgrounds(page, box, get_image_from_uri, layout_children: bool = True, style=None) -> None: ... -def layout_background_layer(box, page, resolution, image, size, clip, repeat, origin, position, attachment): ... -def layout_backgrounds(page, get_image_from_uri) -> None: ... diff --git a/stubs/weasyprint/weasyprint/layout/block.pyi b/stubs/weasyprint/weasyprint/layout/block.pyi deleted file mode 100644 index bd31407dcdea..000000000000 --- a/stubs/weasyprint/weasyprint/layout/block.pyi +++ /dev/null @@ -1,70 +0,0 @@ -def block_level_layout( - context, - box, - bottom_space, - skip_stack, - containing_block, - page_is_empty: bool = True, - absolute_boxes=None, - fixed_boxes=None, - adjoining_margins=None, - first_letter_style=None, - first_line_style=None, - discard: bool = False, - max_lines=None, -): ... -def block_level_layout_switch( - context, - box, - bottom_space, - skip_stack, - containing_block, - page_is_empty, - absolute_boxes, - fixed_boxes, - adjoining_margins, - first_letter_style, - first_line_style, - discard, - max_lines, -): ... -def block_box_layout( - context, - box, - bottom_space, - skip_stack, - containing_block, - page_is_empty, - absolute_boxes, - fixed_boxes, - adjoining_margins, - first_letter_style, - first_line_style, - discard, - max_lines, -): ... -def block_level_width(box, containing_block, with_min_max: bool = True) -> None: ... -def relative_positioning(box, containing_block) -> None: ... -def block_container_layout( - context, - box, - bottom_space, - skip_stack, - page_is_empty, - absolute_boxes, - fixed_boxes, - adjoining_margins, - first_letter_style, - first_line_style, - discard, - max_lines, -): ... -def collapse_margin(adjoining_margins): ... -def block_level_page_break(sibling_before, sibling_after): ... -def block_level_page_name(sibling_before, sibling_after): ... -def find_earlier_page_break(context, children, absolute_boxes, fixed_boxes): ... -def find_last_in_flow_child(children): ... -def reversed_enumerate(seq): ... -def remove_placeholders(context, box_list, absolute_boxes, fixed_boxes) -> None: ... -def avoid_page_break(page_break, context): ... -def force_page_break(page_break, context): ... diff --git a/stubs/weasyprint/weasyprint/layout/column.pyi b/stubs/weasyprint/weasyprint/layout/column.pyi deleted file mode 100644 index 848d09c38da2..000000000000 --- a/stubs/weasyprint/weasyprint/layout/column.pyi +++ /dev/null @@ -1,13 +0,0 @@ -def columns_layout( - context, - box, - bottom_space, - skip_stack, - containing_block, - page_is_empty, - absolute_boxes, - fixed_boxes, - adjoining_margins, - first_letter_style, - first_line_style, -): ... diff --git a/stubs/weasyprint/weasyprint/layout/flex.pyi b/stubs/weasyprint/weasyprint/layout/flex.pyi deleted file mode 100644 index bd73d04d2091..000000000000 --- a/stubs/weasyprint/weasyprint/layout/flex.pyi +++ /dev/null @@ -1,5 +0,0 @@ -class FlexLine(list): ... - -def flex_layout( - context, box, bottom_space, skip_stack, containing_block, page_is_empty, absolute_boxes, fixed_boxes, discard -): ... diff --git a/stubs/weasyprint/weasyprint/layout/float.pyi b/stubs/weasyprint/weasyprint/layout/float.pyi deleted file mode 100644 index d7da34650ed5..000000000000 --- a/stubs/weasyprint/weasyprint/layout/float.pyi +++ /dev/null @@ -1,8 +0,0 @@ -from .min_max import handle_min_max_width - -@handle_min_max_width -def float_width(box, context, containing_block) -> None: ... -def float_layout(context, box, containing_block, absolute_boxes, fixed_boxes, bottom_space, skip_stack): ... -def find_float_position(context, box, containing_block): ... -def get_clearance(context, box, direction, collapsed_margin: int = 0): ... -def avoid_collisions(context, box, containing_block, outer: bool = True): ... diff --git a/stubs/weasyprint/weasyprint/layout/grid.pyi b/stubs/weasyprint/weasyprint/layout/grid.pyi deleted file mode 100644 index ffaaeb5cbbbd..000000000000 --- a/stubs/weasyprint/weasyprint/layout/grid.pyi +++ /dev/null @@ -1 +0,0 @@ -def grid_layout(context, box, bottom_space, skip_stack, containing_block, page_is_empty, absolute_boxes, fixed_boxes): ... diff --git a/stubs/weasyprint/weasyprint/layout/inline.pyi b/stubs/weasyprint/weasyprint/layout/inline.pyi deleted file mode 100644 index 79da8a9c49a5..000000000000 --- a/stubs/weasyprint/weasyprint/layout/inline.pyi +++ /dev/null @@ -1,80 +0,0 @@ -from _typeshed import Incomplete -from collections.abc import Generator - -from .min_max import handle_min_max_width - -def iter_line_boxes( - context, - box, - position_y, - bottom_space, - skip_stack, - containing_block, - absolute_boxes, - fixed_boxes, - first_letter_style, - first_line_style, -) -> Generator[Incomplete]: ... -def get_next_linebox( - context, - linebox, - position_y, - bottom_space, - skip_stack, - containing_block, - absolute_boxes, - fixed_boxes, - first_letter_style, - first_line_style, -): ... -def skip_first_whitespace(box, skip_stack): ... -def remove_last_whitespace(context, line) -> None: ... -def first_letter_to_box(box, skip_stack, first_letter_style): ... -def atomic_box(context, box, position_x, skip_stack, containing_block, absolute_boxes, fixed_boxes): ... -def inline_block_box_layout(context, box, position_x, skip_stack, containing_block, absolute_boxes, fixed_boxes): ... -def inline_block_baseline(box): ... -@handle_min_max_width -def inline_block_width(box, context, containing_block) -> None: ... -def split_inline_level( - context, - box, - position_x, - max_x, - bottom_space, - skip_stack, - containing_block, - absolute_boxes, - fixed_boxes, - line_placeholders, - waiting_floats, - line_children, - first_letter_style, - first_line_style, -): ... -def split_inline_box( - context, - box, - position_x, - max_x, - bottom_space, - skip_stack, - containing_block, - absolute_boxes, - fixed_boxes, - line_placeholders, - waiting_floats, - line_children, - first_letter_style, - first_line_style, -): ... -def split_text_box(context, box, available_width, skip, is_line_start: bool = True): ... -def line_box_verticality(box): ... -def translate_subtree(box, dy) -> None: ... -def aligned_subtree_verticality(box, top_bottom_subtrees, baseline_y): ... -def inline_box_verticality(box, top_bottom_subtrees, baseline_y): ... -def text_align(context, line, available_width, last): ... -def justify_line(context, line, extra_width) -> None: ... -def count_expandable_spaces(box): ... -def add_word_spacing(context, box, justification_spacing, x_advance): ... -def is_phantom_linebox(linebox): ... -def can_break_inside(box): ... diff --git a/stubs/weasyprint/weasyprint/layout/leader.pyi b/stubs/weasyprint/weasyprint/layout/leader.pyi deleted file mode 100644 index d976c641a8d0..000000000000 --- a/stubs/weasyprint/weasyprint/layout/leader.pyi +++ /dev/null @@ -1,2 +0,0 @@ -def leader_index(box): ... -def handle_leader(context, line, containing_block) -> None: ... diff --git a/stubs/weasyprint/weasyprint/layout/min_max.pyi b/stubs/weasyprint/weasyprint/layout/min_max.pyi deleted file mode 100644 index 8bba11f54c73..000000000000 --- a/stubs/weasyprint/weasyprint/layout/min_max.pyi +++ /dev/null @@ -1,2 +0,0 @@ -def handle_min_max_width(function): ... -def handle_min_max_height(function): ... diff --git a/stubs/weasyprint/weasyprint/layout/page.pyi b/stubs/weasyprint/weasyprint/layout/page.pyi deleted file mode 100644 index 58f1e258b8a2..000000000000 --- a/stubs/weasyprint/weasyprint/layout/page.pyi +++ /dev/null @@ -1,67 +0,0 @@ -from _typeshed import Incomplete -from collections.abc import Generator -from typing import NamedTuple - -from .min_max import handle_min_max_height, handle_min_max_width - -class PageType(NamedTuple): - side: Incomplete - blank: Incomplete - name: Incomplete - index: Incomplete - groups: Incomplete - -class OrientedBox: - @property - def sugar(self): ... - @property - def outer(self): ... - inner: Incomplete - @outer.setter - def outer(self, new_outer_width) -> None: ... - @property - def outer_min_content_size(self): ... - @property - def outer_max_content_size(self): ... - -class VerticalBox(OrientedBox): - context: Incomplete - box: Incomplete - inner: Incomplete - margin_a: Incomplete - margin_b: Incomplete - padding_plus_border: Incomplete - def __init__(self, context, box) -> None: ... - def restore_box_attributes(self) -> None: ... - @property - def min_content_size(self): ... - @property - def max_content_size(self): ... - -class HorizontalBox(OrientedBox): - context: Incomplete - box: Incomplete - inner: Incomplete - margin_a: Incomplete - margin_b: Incomplete - padding_plus_border: Incomplete - def __init__(self, context, box) -> None: ... - def restore_box_attributes(self) -> None: ... - @property - def min_content_size(self): ... - @property - def max_content_size(self): ... - -def compute_fixed_dimension(context, box, outer, vertical, top_or_left) -> None: ... -def compute_variable_dimension(context, side_boxes, vertical, available_size) -> None: ... -def make_margin_boxes(context, page, state) -> Generator[Incomplete, None, Incomplete]: ... -def margin_box_content_layout(context, page, box): ... -def page_width_or_height(box, containing_block_size) -> None: ... -@handle_min_max_width -def page_width(box, context, containing_block_width) -> None: ... -@handle_min_max_height -def page_height(box, context, containing_block_height) -> None: ... -def make_page(context, root_box, page_type, resume_at, page_number, page_state): ... -def set_page_type_computed_styles(page_type, html, style_for) -> None: ... -def remake_page(index, context, root_box, html): ... -def make_all_pages(context, root_box, html, pages) -> Generator[Incomplete]: ... diff --git a/stubs/weasyprint/weasyprint/layout/percent.pyi b/stubs/weasyprint/weasyprint/layout/percent.pyi deleted file mode 100644 index bc30b37aee7f..000000000000 --- a/stubs/weasyprint/weasyprint/layout/percent.pyi +++ /dev/null @@ -1,6 +0,0 @@ -def percentage(value, computed, refer_to): ... -def resolve_one_percentage(box, property_name, refer_to) -> None: ... -def resolve_position_percentages(box, containing_block) -> None: ... -def resolve_percentages(box, containing_block) -> None: ... -def resolve_radii_percentages(box) -> None: ... -def adjust_box_sizing(box, axis) -> None: ... diff --git a/stubs/weasyprint/weasyprint/layout/preferred.pyi b/stubs/weasyprint/weasyprint/layout/preferred.pyi deleted file mode 100644 index 06b5768980be..000000000000 --- a/stubs/weasyprint/weasyprint/layout/preferred.pyi +++ /dev/null @@ -1,27 +0,0 @@ -from _typeshed import Incomplete -from collections.abc import Generator - -def shrink_to_fit(context, box, available_content_width): ... -def min_content_width(context, box, outer: bool = True): ... -def max_content_width(context, box, outer: bool = True): ... -def min_max(box, width): ... -def margin_width(box, width, left: bool = True, right: bool = True): ... -def adjust(box, outer, width, left: bool = True, right: bool = True): ... -def block_min_content_width(context, box, outer: bool = True): ... -def block_max_content_width(context, box, outer: bool = True): ... -def inline_min_content_width( - context, box, outer: bool = True, skip_stack=None, first_line: bool = False, is_line_start: bool = False -): ... -def inline_max_content_width(context, box, outer: bool = True, is_line_start: bool = False): ... -def column_group_content_width(context, box): ... -def table_cell_min_content_width(context, box, outer): ... -def table_cell_min_max_content_width(context, box, outer: bool = True): ... -def inline_line_widths( - context, box, outer, is_line_start, minimum, skip_stack=None, first_line: bool = False -) -> Generator[Incomplete]: ... -def table_and_columns_preferred_widths(context, box, outer: bool = True): ... -def replaced_min_content_width(box, outer: bool = True): ... -def replaced_max_content_width(box, outer: bool = True): ... -def flex_min_content_width(context, box, outer: bool = True): ... -def flex_max_content_width(context, box, outer: bool = True): ... -def trailing_whitespace_size(context, box): ... diff --git a/stubs/weasyprint/weasyprint/layout/replaced.pyi b/stubs/weasyprint/weasyprint/layout/replaced.pyi deleted file mode 100644 index 6b16f9a649c3..000000000000 --- a/stubs/weasyprint/weasyprint/layout/replaced.pyi +++ /dev/null @@ -1,18 +0,0 @@ -from .min_max import handle_min_max_height, handle_min_max_width - -def default_image_sizing( - intrinsic_width, intrinsic_height, intrinsic_ratio, specified_width, specified_height, default_width, default_height -): ... -def contain_constraint_image_sizing(constraint_width, constraint_height, intrinsic_ratio): ... -def cover_constraint_image_sizing(constraint_width, constraint_height, intrinsic_ratio): ... -def replacedbox_layout(box): ... -@handle_min_max_width -def replaced_box_width(box, containing_block) -> None: ... -@handle_min_max_height -def replaced_box_height(box) -> None: ... -def inline_replaced_box_layout(box, containing_block) -> None: ... -def inline_replaced_box_width_height(box, containing_block) -> None: ... -def min_max_auto_replaced(box) -> None: ... -def block_replaced_box_layout(context, box, containing_block): ... -@handle_min_max_width -def block_replaced_width(box, containing_block) -> None: ... diff --git a/stubs/weasyprint/weasyprint/layout/table.pyi b/stubs/weasyprint/weasyprint/layout/table.pyi deleted file mode 100644 index bfc8487322b7..000000000000 --- a/stubs/weasyprint/weasyprint/layout/table.pyi +++ /dev/null @@ -1,23 +0,0 @@ -from _typeshed import Incomplete - -def table_layout(context, table, bottom_space, skip_stack, containing_block, page_is_empty, absolute_boxes, fixed_boxes): ... -def add_top_padding(box, extra_padding) -> None: ... -def fixed_table_layout(box) -> None: ... -def auto_table_layout(context, box, containing_block) -> None: ... -def table_wrapper_width(context, wrapper, containing_block) -> None: ... -def cell_baseline(cell): ... -def find_in_flow_baseline(box, last: bool = False, baseline_types=...): ... -def distribute_excess_width( - context, - grid, - excess_width, - column_widths, - constrainedness, - column_intrinsic_percentages, - column_max_content_widths, - column_slice=..., -) -> None: ... - -TRANSPARENT: Incomplete - -def collapse_table_borders(table, grid_width, grid_height): ... diff --git a/stubs/weasyprint/weasyprint/logger.pyi b/stubs/weasyprint/weasyprint/logger.pyi deleted file mode 100644 index 29097aea7d91..000000000000 --- a/stubs/weasyprint/weasyprint/logger.pyi +++ /dev/null @@ -1,4 +0,0 @@ -from _typeshed import Incomplete - -LOGGER: Incomplete -PROGRESS_LOGGER: Incomplete diff --git a/stubs/weasyprint/weasyprint/matrix.pyi b/stubs/weasyprint/weasyprint/matrix.pyi deleted file mode 100644 index 603ceb1a3d6b..000000000000 --- a/stubs/weasyprint/weasyprint/matrix.pyi +++ /dev/null @@ -1,10 +0,0 @@ -class Matrix(list): - def __init__(self, a: int = 1, b: int = 0, c: int = 0, d: int = 1, e: int = 0, f: int = 0, matrix=None) -> None: ... - def __matmul__(self, other): ... - @property - def invert(self): ... - @property - def determinant(self): ... - def transform_point(self, x, y): ... - @property - def values(self): ... diff --git a/stubs/weasyprint/weasyprint/pdf/__init__.pyi b/stubs/weasyprint/weasyprint/pdf/__init__.pyi deleted file mode 100644 index a6613c97e5f3..000000000000 --- a/stubs/weasyprint/weasyprint/pdf/__init__.pyi +++ /dev/null @@ -1,5 +0,0 @@ -from _typeshed import Incomplete - -VARIANTS: Incomplete - -def generate_pdf(document, target, zoom, **options): ... diff --git a/stubs/weasyprint/weasyprint/pdf/anchors.pyi b/stubs/weasyprint/weasyprint/pdf/anchors.pyi deleted file mode 100644 index e5c014d888ee..000000000000 --- a/stubs/weasyprint/weasyprint/pdf/anchors.pyi +++ /dev/null @@ -1,11 +0,0 @@ -from _typeshed import Incomplete -from collections.abc import Generator - -MIMETYPES: Incomplete - -def add_links(links_and_anchors, matrix, pdf, page, names, tags) -> None: ... -def add_outlines(pdf, bookmarks, parent=None): ... -def add_forms(forms, matrix, pdf, page, resources, stream, font_map) -> None: ... -def add_annotations(links, matrix, document, pdf, page, annot_files, compress) -> None: ... -def write_pdf_attachment(pdf, attachment, compress): ... -def resolve_links(pages) -> Generator[Incomplete]: ... diff --git a/stubs/weasyprint/weasyprint/pdf/debug.pyi b/stubs/weasyprint/weasyprint/pdf/debug.pyi deleted file mode 100644 index 7472ba8d9362..000000000000 --- a/stubs/weasyprint/weasyprint/pdf/debug.pyi +++ /dev/null @@ -1,5 +0,0 @@ -from _typeshed import Incomplete - -def debug(pdf, metadata, document, page_streams, attachments, compress) -> None: ... - -VARIANTS: Incomplete diff --git a/stubs/weasyprint/weasyprint/pdf/fonts.pyi b/stubs/weasyprint/weasyprint/pdf/fonts.pyi deleted file mode 100644 index 23ddfe40ac05..000000000000 --- a/stubs/weasyprint/weasyprint/pdf/fonts.pyi +++ /dev/null @@ -1,38 +0,0 @@ -from _typeshed import Incomplete - -class Font: - hb_font: Incomplete - hb_face: Incomplete - file_content: Incomplete - index: Incomplete - font_size: Incomplete - style: Incomplete - family: Incomplete - variations: Incomplete - weight: Incomplete - hash: Incomplete - name: Incomplete - ascent: Incomplete - descent: Incomplete - tables: Incomplete - bitmap: bool - italic_angle: int - upem: Incomplete - png: Incomplete - svg: Incomplete - glyph_count: Incomplete - stemv: int - stemh: int - widths: Incomplete - to_unicode: Incomplete - missing: Incomplete - used_in_forms: bool - flags: Incomplete - def __init__(self, pango_font, description, font_size) -> None: ... - def get_unused_glyph_id(self, codepoint): ... - def clean(self, to_unicode, hinting) -> None: ... - @property - def type(self): ... - def subset(self, to_unicode, hinting) -> None: ... - -def build_fonts_dictionary(pdf, fonts, compress, subset, options): ... diff --git a/stubs/weasyprint/weasyprint/pdf/metadata.pyi b/stubs/weasyprint/weasyprint/pdf/metadata.pyi deleted file mode 100644 index d21b9b9cc779..000000000000 --- a/stubs/weasyprint/weasyprint/pdf/metadata.pyi +++ /dev/null @@ -1,32 +0,0 @@ -from _typeshed import Incomplete - -NS: Incomplete - -class DocumentMetadata: - title: Incomplete - authors: Incomplete - description: Incomplete - keywords: Incomplete - generator: Incomplete - created: Incomplete - modified: Incomplete - attachments: Incomplete - lang: Incomplete - custom: Incomplete - xmp_metadata: Incomplete - def __init__( - self, - title=None, - authors=None, - description=None, - keywords=None, - generator=None, - created=None, - modified=None, - attachments=None, - lang=None, - custom=None, - xmp_metadata=None, - ) -> None: ... - def include_in_pdf(self, pdf, variant, version, conformance, compress) -> None: ... - def generate_rdf_metadata(self, variant, version, conformance): ... diff --git a/stubs/weasyprint/weasyprint/pdf/pdfa.pyi b/stubs/weasyprint/weasyprint/pdf/pdfa.pyi deleted file mode 100644 index d0108cd87f44..000000000000 --- a/stubs/weasyprint/weasyprint/pdf/pdfa.pyi +++ /dev/null @@ -1,5 +0,0 @@ -from _typeshed import Incomplete - -def pdfa(pdf, document, page_streams, attachments, compress, version, variant) -> None: ... - -VARIANTS: Incomplete diff --git a/stubs/weasyprint/weasyprint/pdf/pdfua.pyi b/stubs/weasyprint/weasyprint/pdf/pdfua.pyi deleted file mode 100644 index c55404defad9..000000000000 --- a/stubs/weasyprint/weasyprint/pdf/pdfua.pyi +++ /dev/null @@ -1,5 +0,0 @@ -from _typeshed import Incomplete - -def pdfua(pdf, document, page_streams, attachments, compress, version) -> None: ... - -VARIANTS: Incomplete diff --git a/stubs/weasyprint/weasyprint/pdf/pdfx.pyi b/stubs/weasyprint/weasyprint/pdf/pdfx.pyi deleted file mode 100644 index 3e001eef1cbf..000000000000 --- a/stubs/weasyprint/weasyprint/pdf/pdfx.pyi +++ /dev/null @@ -1,5 +0,0 @@ -from _typeshed import Incomplete - -def pdfx(pdf, document, page_streams, attachments, compress, version, variant) -> None: ... - -VARIANTS: Incomplete diff --git a/stubs/weasyprint/weasyprint/pdf/stream.pyi b/stubs/weasyprint/weasyprint/pdf/stream.pyi deleted file mode 100644 index 4ad92e2c2cf3..000000000000 --- a/stubs/weasyprint/weasyprint/pdf/stream.pyi +++ /dev/null @@ -1,43 +0,0 @@ -from _typeshed import Incomplete -from collections.abc import Generator -from contextlib import contextmanager - -import pydyf - -class Stream(pydyf.Stream): - page_rectangle: Incomplete - length: Incomplete - ink_rect: Incomplete - logical_rect: Incomplete - def __init__( - self, fonts, page_rectangle, resources, images, tags, color_profiles, output_intent, *args, **kwargs - ) -> None: ... - def clone(self, **kwargs): ... - @property - def ctm(self): ... - def push_state(self) -> None: ... - def pop_state(self) -> None: ... - def transform(self, a: int = 1, b: int = 0, c: int = 0, d: int = 1, e: int = 0, f: int = 0) -> None: ... - def begin_text(self) -> None: ... - def end_text(self) -> None: ... - def set_color(self, color, stroke: bool = False) -> None: ... - def set_font_size(self, font, size) -> None: ... - def set_state(self, state) -> None: ... - def set_alpha(self, alpha, stroke: bool = False, fill=None) -> None: ... - def set_alpha_state(self, x, y, width, height, mode: str = "luminosity"): ... - def set_blend_mode(self, mode) -> None: ... - def add_font(self, pango_font): ... - def add_group(self, x, y, width, height): ... - def add_image(self, image, interpolate, ratio): ... - def add_pattern(self, x, y, width, height, repeat_width, repeat_height, matrix): ... - def add_shading(self, shading_type, domain, coords, extend, function, color_space=None): ... - @contextmanager - def stacked(self) -> Generator[None]: ... - @contextmanager - def marked(self, box, tag) -> Generator[None]: ... - @contextmanager - def artifact(self) -> Generator[None]: ... - @staticmethod - def create_interpolation_function(domain, c0, c1, n): ... - @staticmethod - def create_stitching_function(domain, encode, bounds, sub_functions): ... diff --git a/stubs/weasyprint/weasyprint/pdf/tags.pyi b/stubs/weasyprint/weasyprint/pdf/tags.pyi deleted file mode 100644 index 57f085604ad6..000000000000 --- a/stubs/weasyprint/weasyprint/pdf/tags.pyi +++ /dev/null @@ -1 +0,0 @@ -def add_tags(pdf, document, pdf_version, page_streams) -> None: ... diff --git a/stubs/weasyprint/weasyprint/stacking.pyi b/stubs/weasyprint/weasyprint/stacking.pyi deleted file mode 100644 index 79e0960f6394..000000000000 --- a/stubs/weasyprint/weasyprint/stacking.pyi +++ /dev/null @@ -1,17 +0,0 @@ -from _typeshed import Incomplete - -class StackingContext: - box: Incomplete - page: Incomplete - block_level_boxes: Incomplete - float_contexts: Incomplete - negative_z_contexts: Incomplete - zero_z_contexts: Incomplete - positive_z_contexts: Incomplete - blocks_and_cells: Incomplete - z_index: Incomplete - def __init__(self, box, child_contexts, blocks, floats, blocks_and_cells, page) -> None: ... - @classmethod - def from_page(cls, page): ... - @classmethod - def from_box(cls, box, page, child_contexts=None): ... diff --git a/stubs/weasyprint/weasyprint/svg/__init__.pyi b/stubs/weasyprint/weasyprint/svg/__init__.pyi deleted file mode 100644 index 97a0721b0ce8..000000000000 --- a/stubs/weasyprint/weasyprint/svg/__init__.pyi +++ /dev/null @@ -1,86 +0,0 @@ -from _typeshed import Incomplete - -TAGS: Incomplete -NOT_INHERITED_ATTRIBUTES: Incomplete -COLOR_ATTRIBUTES: Incomplete -DEF_TYPES: Incomplete - -class Node: - attrib: Incomplete - vertices: Incomplete - bounding_box: Incomplete - def __init__(self, wrapper, style) -> None: ... - def copy(self): ... - def get(self, key, default=None): ... - @property - def tag(self): ... - @property - def text(self): ... - @property - def tail(self): ... - @property - def display(self): ... - @property - def visible(self): ... - def cascade(self, child) -> None: ... - def __iter__(self): ... - def get_viewbox(self): ... - def get_href(self, base_url): ... - def del_href(self) -> None: ... - @staticmethod - def process_whitespace(string, preserve): ... - def get_child(self, id_): ... - def text_children(self, element, trailing_space, text_root: bool = False): ... - def flatten(self): ... - def pop_rotation(self, original_rotate, rotate) -> None: ... - __class__: Incomplete - def override_iter(self, iterator): ... - def set_svg_size(self, svg, concrete_width, concrete_height) -> None: ... - -class LazyDefs: - def __init__(self, name, svg) -> None: ... - def __getitem__(self, name): ... - def get(self, name): ... - def __contains__(self, name) -> bool: ... - -class SVG: - tree: Incomplete - font_config: Incomplete - url_fetcher: Incomplete - url: Incomplete - filters: Incomplete - gradients: Incomplete - images: Incomplete - markers: Incomplete - masks: Incomplete - patterns: Incomplete - paths: Incomplete - symbols: Incomplete - use_cache: Incomplete - cursor_position: Incomplete - cursor_d_position: Incomplete - text_path_width: int - def __init__(self, tree, url, font_config, url_fetcher=None) -> None: ... - def get_intrinsic_size(self, font_size): ... - def get_viewbox(self): ... - def point(self, x, y, font_size): ... - def length(self, length, font_size): ... - stream: Incomplete - base_url: Incomplete - context: Incomplete - def draw(self, stream, concrete_width, concrete_height, base_url, context) -> None: ... - def draw_node(self, node, font_size, fill_stroke: bool = True) -> None: ... - def draw_markers(self, node, font_size, fill_stroke) -> None: ... - @staticmethod - def get_paint(value): ... - def set_graphical_state(self, node, font_size, text: bool = False) -> None: ... - def fill_stroke(self, node, font_size, text: bool = False) -> None: ... - def transform(self, node, font_size) -> None: ... - def inherit_element(self, element, defs) -> None: ... - def calculate_bounding_box(self, node, font_size, stroke: bool = True): ... - -class Pattern(SVG): - svg: Incomplete - tree: Incomplete - def __init__(self, tree, svg) -> None: ... - def draw_node(self, node, font_size, fill_stroke: bool = True) -> None: ... diff --git a/stubs/weasyprint/weasyprint/svg/bounding_box.pyi b/stubs/weasyprint/weasyprint/svg/bounding_box.pyi deleted file mode 100644 index 8672e182c4c3..000000000000 --- a/stubs/weasyprint/weasyprint/svg/bounding_box.pyi +++ /dev/null @@ -1,18 +0,0 @@ -from _typeshed import Incomplete - -EMPTY_BOUNDING_BOX: Incomplete - -def bounding_box(svg, node, font_size, stroke): ... -def bounding_box_rect(svg, node, font_size): ... -def bounding_box_circle(svg, node, font_size): ... -def bounding_box_ellipse(svg, node, font_size): ... -def bounding_box_line(svg, node, font_size): ... -def bounding_box_polyline(svg, node, font_size): ... -def bounding_box_path(svg, node, font_size): ... -def bounding_box_text(svg, node, font_size): ... -def bounding_box_g(svg, node, font_size): ... -def bounding_box_use(svg, node, font_size): ... -def extend_bounding_box(bounding_box, points): ... -def is_valid_bounding_box(bounding_box): ... - -BOUNDING_BOX_METHODS: Incomplete diff --git a/stubs/weasyprint/weasyprint/svg/css.pyi b/stubs/weasyprint/weasyprint/svg/css.pyi deleted file mode 100644 index 9a77a533fd9f..000000000000 --- a/stubs/weasyprint/weasyprint/svg/css.pyi +++ /dev/null @@ -1,6 +0,0 @@ -from _typeshed import Incomplete -from collections.abc import Generator - -def find_stylesheets_rules(tree, stylesheet_rules, url, font_config, url_fetcher) -> Generator[Incomplete, Incomplete]: ... -def parse_declarations(input): ... -def parse_stylesheets(tree, url, font_config, url_fetcher): ... diff --git a/stubs/weasyprint/weasyprint/svg/defs.pyi b/stubs/weasyprint/weasyprint/svg/defs.pyi deleted file mode 100644 index 927da3debcb4..000000000000 --- a/stubs/weasyprint/weasyprint/svg/defs.pyi +++ /dev/null @@ -1,9 +0,0 @@ -def get_use_tree(svg, node, font_size): ... -def use(svg, node, font_size) -> None: ... -def draw_gradient_or_pattern(svg, node, name, font_size, opacity, stroke): ... -def draw_gradient(svg, node, gradient, font_size, opacity, stroke): ... -def spread_linear_gradient(spread, positions, colors, x1, y1, x2, y2, bounding_box, matrix): ... -def spread_radial_gradient(spread, positions, colors, fx, fy, fr, cx, cy, r, width, height, matrix): ... -def draw_pattern(svg, node, pattern, font_size, opacity, stroke): ... -def apply_filters(svg, node, filter_node, font_size) -> None: ... -def paint_mask(svg, node, mask, font_size) -> None: ... diff --git a/stubs/weasyprint/weasyprint/svg/images.pyi b/stubs/weasyprint/weasyprint/svg/images.pyi deleted file mode 100644 index a038f73dcdd0..000000000000 --- a/stubs/weasyprint/weasyprint/svg/images.pyi +++ /dev/null @@ -1,2 +0,0 @@ -def svg(svg, node, font_size) -> None: ... -def image(svg, node, font_size) -> None: ... diff --git a/stubs/weasyprint/weasyprint/svg/path.pyi b/stubs/weasyprint/weasyprint/svg/path.pyi deleted file mode 100644 index 9147064eb76c..000000000000 --- a/stubs/weasyprint/weasyprint/svg/path.pyi +++ /dev/null @@ -1,3 +0,0 @@ -PATH_LETTERS: str - -def path(svg, node, font_size) -> None: ... diff --git a/stubs/weasyprint/weasyprint/svg/shapes.pyi b/stubs/weasyprint/weasyprint/svg/shapes.pyi deleted file mode 100644 index ec8a59000fa7..000000000000 --- a/stubs/weasyprint/weasyprint/svg/shapes.pyi +++ /dev/null @@ -1,6 +0,0 @@ -def circle(svg, node, font_size) -> None: ... -def ellipse(svg, node, font_size) -> None: ... -def rect(svg, node, font_size) -> None: ... -def line(svg, node, font_size) -> None: ... -def polygon(svg, node, font_size) -> None: ... -def polyline(svg, node, font_size) -> None: ... diff --git a/stubs/weasyprint/weasyprint/svg/text.pyi b/stubs/weasyprint/weasyprint/svg/text.pyi deleted file mode 100644 index 5f9b56aa37b2..000000000000 --- a/stubs/weasyprint/weasyprint/svg/text.pyi +++ /dev/null @@ -1,12 +0,0 @@ -from _typeshed import Incomplete - -class TextBox: - pango_layout: Incomplete - style: Incomplete - def __init__(self, pango_layout, style) -> None: ... - @property - def text(self): ... - -class Style(dict): ... - -def text(svg, node, font_size) -> None: ... diff --git a/stubs/weasyprint/weasyprint/svg/utils.pyi b/stubs/weasyprint/weasyprint/svg/utils.pyi deleted file mode 100644 index 35a15c6ecfa7..000000000000 --- a/stubs/weasyprint/weasyprint/svg/utils.pyi +++ /dev/null @@ -1,11 +0,0 @@ -class PointError(Exception): ... - -def normalize(string): ... -def size(string, font_size=None, percentage_reference=None): ... -def angle(string): ... -def alpha_value(value): ... -def point(svg, string, font_size): ... -def preserve_ratio(svg, node, font_size, width, height, viewbox=None): ... -def parse_url(url): ... -def color(string): ... -def transform(transform_string, transform_origin, font_size, normalized_diagonal): ... From dd8d51f350205cb0000c25d8bd4b9e81d367d705 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 Jul 2026 16:31:00 +0000 Subject: [PATCH 17/56] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/weasyprint/weasyprint/__init__.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/weasyprint/weasyprint/__init__.pyi b/stubs/weasyprint/weasyprint/__init__.pyi index 373f710edf82..5239bda3f414 100644 --- a/stubs/weasyprint/weasyprint/__init__.pyi +++ b/stubs/weasyprint/weasyprint/__init__.pyi @@ -2,8 +2,8 @@ from _typeshed import Incomplete from collections.abc import Callable from datetime import datetime from pathlib import Path -from typing import IO, Any, TypedDict -from typing_extensions import TypeAlias, Unpack +from typing import IO, Any, TypeAlias, TypedDict +from typing_extensions import Unpack from xml.etree.ElementTree import Element from csselect2 import ElementWrapper, Matcher From 1d953f4cb9f9a20b5b153a04b5bf183cc70b1df9 Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 18:35:41 +0200 Subject: [PATCH 18/56] Add FontConfiguration stub --- stubs/weasyprint/weasyprint/text/fonts.pyi | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 stubs/weasyprint/weasyprint/text/fonts.pyi diff --git a/stubs/weasyprint/weasyprint/text/fonts.pyi b/stubs/weasyprint/weasyprint/text/fonts.pyi new file mode 100644 index 000000000000..5a090d06cd6a --- /dev/null +++ b/stubs/weasyprint/weasyprint/text/fonts.pyi @@ -0,0 +1,2 @@ +class FontConfiguration: + pass From a32a50784b2a069558b6460cc5414f4301453727 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 Jul 2026 16:38:01 +0000 Subject: [PATCH 19/56] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/weasyprint/weasyprint/text/fonts.pyi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stubs/weasyprint/weasyprint/text/fonts.pyi b/stubs/weasyprint/weasyprint/text/fonts.pyi index 5a090d06cd6a..c90acca466c2 100644 --- a/stubs/weasyprint/weasyprint/text/fonts.pyi +++ b/stubs/weasyprint/weasyprint/text/fonts.pyi @@ -1,2 +1 @@ -class FontConfiguration: - pass +class FontConfiguration: ... From 7a85e566b434e0e64e284c1e3d0c7cb14aa28d47 Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 18:40:16 +0200 Subject: [PATCH 20/56] Try adding dependencies --- stubs/weasyprint/METADATA.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/stubs/weasyprint/METADATA.toml b/stubs/weasyprint/METADATA.toml index 46146db8cc8e..6b3c36864c9b 100644 --- a/stubs/weasyprint/METADATA.toml +++ b/stubs/weasyprint/METADATA.toml @@ -1,2 +1,3 @@ version = "69.0.*" upstream-repository = "https://github.com/Kozea/WeasyPrint" +dependencies = ["csselect2", "pypdf"] From 1abc58da06475102e236251fab95e6ffcdd029ba Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 18:41:17 +0200 Subject: [PATCH 21/56] Add two typehints for urls.py --- stubs/weasyprint/weasyprint/urls.pyi | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/stubs/weasyprint/weasyprint/urls.pyi b/stubs/weasyprint/weasyprint/urls.pyi index bb5a8d2691d0..c770574dfe56 100644 --- a/stubs/weasyprint/weasyprint/urls.pyi +++ b/stubs/weasyprint/weasyprint/urls.pyi @@ -1,7 +1,8 @@ import contextlib from _typeshed import Incomplete -from collections.abc import Generator +from collections.abc import Generator, Sequence from gzip import GzipFile +from ssl import SSLContext from urllib import request UNICODE_SCHEME_RE: Incomplete @@ -43,9 +44,9 @@ class URLFetcher(request.OpenerDirector): def __init__( self, timeout: int = 10, - ssl_context=None, - http_headers=None, - allowed_protocols=None, + ssl_context: SSLContext | None = None, + http_headers = None, + allowed_protocols: Sequence[str] | None = None, allow_redirects: bool = True, fail_on_errors: bool = False, **kwargs, From e0fb952db5db09c753dbb3728fb09fc22c41e940 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 Jul 2026 16:49:29 +0000 Subject: [PATCH 22/56] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/weasyprint/weasyprint/urls.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/weasyprint/weasyprint/urls.pyi b/stubs/weasyprint/weasyprint/urls.pyi index c770574dfe56..5bd82e5bcd3d 100644 --- a/stubs/weasyprint/weasyprint/urls.pyi +++ b/stubs/weasyprint/weasyprint/urls.pyi @@ -45,7 +45,7 @@ class URLFetcher(request.OpenerDirector): self, timeout: int = 10, ssl_context: SSLContext | None = None, - http_headers = None, + http_headers=None, allowed_protocols: Sequence[str] | None = None, allow_redirects: bool = True, fail_on_errors: bool = False, From 7c28b5a4ed6e77089354a901f45061c4f1f6f8fa Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 18:49:27 +0200 Subject: [PATCH 23/56] Remove dependency which does not have any types provided --- stubs/weasyprint/METADATA.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/weasyprint/METADATA.toml b/stubs/weasyprint/METADATA.toml index 6b3c36864c9b..f3b611257797 100644 --- a/stubs/weasyprint/METADATA.toml +++ b/stubs/weasyprint/METADATA.toml @@ -1,3 +1,3 @@ version = "69.0.*" upstream-repository = "https://github.com/Kozea/WeasyPrint" -dependencies = ["csselect2", "pypdf"] +dependencies = ["pypdf"] From a12072432e690a102bcd24f1686b096b44967a5d Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 18:50:06 +0200 Subject: [PATCH 24/56] Cheaply stub types for now --- stubs/weasyprint/weasyprint/__init__.pyi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stubs/weasyprint/weasyprint/__init__.pyi b/stubs/weasyprint/weasyprint/__init__.pyi index 5239bda3f414..4222da81aeb2 100644 --- a/stubs/weasyprint/weasyprint/__init__.pyi +++ b/stubs/weasyprint/weasyprint/__init__.pyi @@ -6,7 +6,6 @@ from typing import IO, Any, TypeAlias, TypedDict from typing_extensions import Unpack from xml.etree.ElementTree import Element -from csselect2 import ElementWrapper, Matcher from pypdf import PDF from .css import ColorProfile @@ -15,6 +14,9 @@ from .document import Document as Document, Page as Page from .text.fonts import FontConfiguration from .urls import URLFetcher, default_url_fetcher as default_url_fetcher +_ElementWrapper: TypeAlias = Any # actually csselect2.ElementWrapper +Matcher: TypeAlias = Any # actually csselect2.Matcher + __all__ = [ "CSS", "DEFAULT_OPTIONS", From 27940ab72df1913a58040284fc5ea0434e0d7981 Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 18:52:27 +0200 Subject: [PATCH 25/56] Consistently apply naming --- stubs/weasyprint/weasyprint/__init__.pyi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stubs/weasyprint/weasyprint/__init__.pyi b/stubs/weasyprint/weasyprint/__init__.pyi index 4222da81aeb2..d56cab101554 100644 --- a/stubs/weasyprint/weasyprint/__init__.pyi +++ b/stubs/weasyprint/weasyprint/__init__.pyi @@ -15,7 +15,7 @@ from .text.fonts import FontConfiguration from .urls import URLFetcher, default_url_fetcher as default_url_fetcher _ElementWrapper: TypeAlias = Any # actually csselect2.ElementWrapper -Matcher: TypeAlias = Any # actually csselect2.Matcher +_Matcher: TypeAlias = Any # actually csselect2.Matcher __all__ = [ "CSS", @@ -64,7 +64,7 @@ class HTML: base_url: str | Path | None # undocumented url_fetcher: URLFetcher # undocumented media_type: str # undocumented - wrapper_element: ElementWrapper # undocumented + wrapper_element: _ElementWrapper # undocumented etree_element: Element # undocumented def __init__( self, @@ -98,7 +98,7 @@ class HTML: class CSS: base_url: str | Path | None # undocumented - matcher: Matcher # undocumented + matcher: _Matcher # undocumented page_rules: list[PageRule] # undocumented layers: list[str] # undocumented def __init__( From 11a204d9de4ef7842ca300e25257ce90c28ac1ac Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 18:56:32 +0200 Subject: [PATCH 26/56] Fix misreading error (it's not pypdf, its pydyf) --- stubs/weasyprint/METADATA.toml | 1 - stubs/weasyprint/weasyprint/__init__.pyi | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/stubs/weasyprint/METADATA.toml b/stubs/weasyprint/METADATA.toml index f3b611257797..46146db8cc8e 100644 --- a/stubs/weasyprint/METADATA.toml +++ b/stubs/weasyprint/METADATA.toml @@ -1,3 +1,2 @@ version = "69.0.*" upstream-repository = "https://github.com/Kozea/WeasyPrint" -dependencies = ["pypdf"] diff --git a/stubs/weasyprint/weasyprint/__init__.pyi b/stubs/weasyprint/weasyprint/__init__.pyi index d56cab101554..e89ed221df37 100644 --- a/stubs/weasyprint/weasyprint/__init__.pyi +++ b/stubs/weasyprint/weasyprint/__init__.pyi @@ -6,8 +6,6 @@ from typing import IO, Any, TypeAlias, TypedDict from typing_extensions import Unpack from xml.etree.ElementTree import Element -from pypdf import PDF - from .css import ColorProfile from .css.counters import CounterStyle from .document import Document as Document, Page as Page @@ -16,6 +14,7 @@ from .urls import URLFetcher, default_url_fetcher as default_url_fetcher _ElementWrapper: TypeAlias = Any # actually csselect2.ElementWrapper _Matcher: TypeAlias = Any # actually csselect2.Matcher +_PDF: TypeAlias = Any # actually pydyf.PDF __all__ = [ "CSS", @@ -89,7 +88,7 @@ class HTML: self, target: str | Path | IO | None = None, zoom: float = 1, - finisher: Callable[[Document, PDF], Any] | None = None, + finisher: Callable[[Document, _PDF], Any] | None = None, font_config: FontConfiguration | None = None, counter_style: CounterStyle | None = None, color_profiles: dict[str, ColorProfile] | None = None, From 8c41e38780ed5bf43348feed011644cbe313a850 Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 19:03:26 +0200 Subject: [PATCH 27/56] Fix typo --- stubs/weasyprint/weasyprint/__init__.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/weasyprint/weasyprint/__init__.pyi b/stubs/weasyprint/weasyprint/__init__.pyi index e89ed221df37..058279a7e405 100644 --- a/stubs/weasyprint/weasyprint/__init__.pyi +++ b/stubs/weasyprint/weasyprint/__init__.pyi @@ -115,7 +115,7 @@ class CSS: font_config: FontConfiguration | None = None, counter_style: CounterStyle | None = None, color_profiles: dict[str, ColorProfile] | None = None, - matcher: Matcher | None = None, + matcher: _Matcher | None = None, page_rules: list[PageRule] | None = None, layers: list[str] | None = None, layer: str | None = None, From 9aa6d4fab990830dfbb6a4552947b507d031dbe6 Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 19:30:19 +0200 Subject: [PATCH 28/56] Use likely more accurate Reader type instead of underspecified IO type --- stubs/weasyprint/weasyprint/__init__.pyi | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/stubs/weasyprint/weasyprint/__init__.pyi b/stubs/weasyprint/weasyprint/__init__.pyi index 058279a7e405..2561e2889c89 100644 --- a/stubs/weasyprint/weasyprint/__init__.pyi +++ b/stubs/weasyprint/weasyprint/__init__.pyi @@ -1,8 +1,9 @@ from _typeshed import Incomplete from collections.abc import Callable from datetime import datetime +from io import Reader from pathlib import Path -from typing import IO, Any, TypeAlias, TypedDict +from typing import Any, TypeAlias, TypedDict from typing_extensions import Unpack from xml.etree.ElementTree import Element @@ -67,10 +68,10 @@ class HTML: etree_element: Element # undocumented def __init__( self, - guess: str | Path | IO | None = None, + guess: str | Path | Reader[str | bytes] | None = None, filename: str | Path | None = None, url: str | None = None, - file_obj: IO | None = None, + file_obj: Reader[str | bytes] | None = None, string: str | None = None, encoding: str | None = None, base_url: str | Path | None = None, @@ -86,7 +87,7 @@ class HTML: ) -> Document: ... def write_pdf( self, - target: str | Path | IO | None = None, + target: str | Path | Reader[str | bytes] | None = None, zoom: float = 1, finisher: Callable[[Document, _PDF], Any] | None = None, font_config: FontConfiguration | None = None, @@ -102,10 +103,10 @@ class CSS: layers: list[str] # undocumented def __init__( self, - guess: str | Path | IO | None = None, + guess: str | Path | Reader[str | bytes] | None = None, filename: str | Path | None = None, url: str | None = None, - file_obj: IO | None = None, + file_obj: Reader[str | bytes] | None = None, string: str | None = None, encoding: str | None = None, base_url: str | Path | None = None, @@ -122,7 +123,7 @@ class CSS: ) -> None: ... class Attachment: - source: tuple[IO, str, str | None, str | None] # undocumented + source: tuple[Reader[str | bytes], str, str | None, str | None] # undocumented name: str | None # undocumented description: str | None # undocumented relationship: str # undocumented @@ -131,10 +132,10 @@ class Attachment: modified: datetime # undocumented def __init__( self, - guess: str | Path | IO | None = None, + guess: str | Path | Reader[str | bytes] | None = None, filename: str | Path | None = None, url: str | None = None, - file_obj: IO | None = None, + file_obj: Reader[str | bytes] | None = None, string: str | None = None, base_url: str | Path | None = None, url_fetcher: URLFetcher | None = None, From df0a6820675f80484a79638e858b1b176f8f0175 Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 19:37:43 +0200 Subject: [PATCH 29/56] Add types to dict --- stubs/weasyprint/weasyprint/css/counters.pyi | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/stubs/weasyprint/weasyprint/css/counters.pyi b/stubs/weasyprint/weasyprint/css/counters.pyi index 1f875fbd05f4..bfdfa77c99a8 100644 --- a/stubs/weasyprint/weasyprint/css/counters.pyi +++ b/stubs/weasyprint/weasyprint/css/counters.pyi @@ -1,8 +1,13 @@ +from _typeshed import Incomplete +from typing_extensions import TypeAlias + def symbol(string_or_url) -> str: ... def parse_counter_style_name(tokens, counter_style): ... -class CounterStyle(dict): - def resolve_counter(self, counter_name, previous_types=None): ... +CounterName: TypeAlias = ... + +class CounterStyle(dict[CounterName, Incomplete]): + def resolve_counter(self, counter_name: CounterName, previous_types=None): ... def render_value(self, counter_value, counter_name=None, counter=None, previous_types=None): ... - def render_marker(self, counter_name, counter_value): ... + def render_marker(self, counter_name: CounterName, counter_value): ... def copy(self) -> CounterStyle: ... From 97e8a13bc44aa7538ca54f3a4ae9dcb3d711a980 Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 19:39:54 +0200 Subject: [PATCH 30/56] Cheap out and just make the dicts all "Incomplete" --- stubs/weasyprint/weasyprint/css/__init__.pyi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stubs/weasyprint/weasyprint/css/__init__.pyi b/stubs/weasyprint/weasyprint/css/__init__.pyi index 03649c0cb44b..d108c8a856a4 100644 --- a/stubs/weasyprint/weasyprint/css/__init__.pyi +++ b/stubs/weasyprint/weasyprint/css/__init__.pyi @@ -31,7 +31,7 @@ def declaration_precedence(origin, importance): ... def resolve_var(computed, token, parent_style): ... def resolve_math(token, computed=None, property_name=None, refer_to=None): ... -class InitialStyle(dict): +class InitialStyle(dict[Incomplete, Incomplete]): parent_style: Incomplete specified: Incomplete cache: Incomplete @@ -39,7 +39,7 @@ class InitialStyle(dict): def __init__(self, font_config) -> None: ... def __missing__(self, key): ... -class AnonymousStyle(dict): +class AnonymousStyle(dict[Incomplete, Incomplete]): parent_style: Incomplete is_root_element: bool specified: Incomplete @@ -49,7 +49,7 @@ class AnonymousStyle(dict): def copy(self): ... def __missing__(self, key): ... -class ComputedStyle(dict): +class ComputedStyle(dict[Incomplete, Incomplete]): specified: Incomplete parent_style: Incomplete cascaded: Incomplete From 12a7f321026183cdc7461513cc1caaafe137ca16 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 Jul 2026 17:42:07 +0000 Subject: [PATCH 31/56] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/weasyprint/weasyprint/css/counters.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/weasyprint/weasyprint/css/counters.pyi b/stubs/weasyprint/weasyprint/css/counters.pyi index bfdfa77c99a8..307d8105978e 100644 --- a/stubs/weasyprint/weasyprint/css/counters.pyi +++ b/stubs/weasyprint/weasyprint/css/counters.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from typing_extensions import TypeAlias +from typing import TypeAlias def symbol(string_or_url) -> str: ... def parse_counter_style_name(tokens, counter_style): ... From 582e91df5418fb70f5fcaa4f6cb5a4845380f914 Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 19:42:15 +0200 Subject: [PATCH 32/56] Revert "Use likely more accurate Reader type instead of underspecified IO type" This reverts commit 9aa6d4fab990830dfbb6a4552947b507d031dbe6. Version too new. --- stubs/weasyprint/weasyprint/__init__.pyi | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/stubs/weasyprint/weasyprint/__init__.pyi b/stubs/weasyprint/weasyprint/__init__.pyi index 2561e2889c89..058279a7e405 100644 --- a/stubs/weasyprint/weasyprint/__init__.pyi +++ b/stubs/weasyprint/weasyprint/__init__.pyi @@ -1,9 +1,8 @@ from _typeshed import Incomplete from collections.abc import Callable from datetime import datetime -from io import Reader from pathlib import Path -from typing import Any, TypeAlias, TypedDict +from typing import IO, Any, TypeAlias, TypedDict from typing_extensions import Unpack from xml.etree.ElementTree import Element @@ -68,10 +67,10 @@ class HTML: etree_element: Element # undocumented def __init__( self, - guess: str | Path | Reader[str | bytes] | None = None, + guess: str | Path | IO | None = None, filename: str | Path | None = None, url: str | None = None, - file_obj: Reader[str | bytes] | None = None, + file_obj: IO | None = None, string: str | None = None, encoding: str | None = None, base_url: str | Path | None = None, @@ -87,7 +86,7 @@ class HTML: ) -> Document: ... def write_pdf( self, - target: str | Path | Reader[str | bytes] | None = None, + target: str | Path | IO | None = None, zoom: float = 1, finisher: Callable[[Document, _PDF], Any] | None = None, font_config: FontConfiguration | None = None, @@ -103,10 +102,10 @@ class CSS: layers: list[str] # undocumented def __init__( self, - guess: str | Path | Reader[str | bytes] | None = None, + guess: str | Path | IO | None = None, filename: str | Path | None = None, url: str | None = None, - file_obj: Reader[str | bytes] | None = None, + file_obj: IO | None = None, string: str | None = None, encoding: str | None = None, base_url: str | Path | None = None, @@ -123,7 +122,7 @@ class CSS: ) -> None: ... class Attachment: - source: tuple[Reader[str | bytes], str, str | None, str | None] # undocumented + source: tuple[IO, str, str | None, str | None] # undocumented name: str | None # undocumented description: str | None # undocumented relationship: str # undocumented @@ -132,10 +131,10 @@ class Attachment: modified: datetime # undocumented def __init__( self, - guess: str | Path | Reader[str | bytes] | None = None, + guess: str | Path | IO | None = None, filename: str | Path | None = None, url: str | None = None, - file_obj: Reader[str | bytes] | None = None, + file_obj: IO | None = None, string: str | None = None, base_url: str | Path | None = None, url_fetcher: URLFetcher | None = None, From bf750731e68e22602ba1a13b40a591ba2b337f17 Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 19:44:32 +0200 Subject: [PATCH 33/56] Add generic annotations --- stubs/weasyprint/weasyprint/__init__.pyi | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/stubs/weasyprint/weasyprint/__init__.pyi b/stubs/weasyprint/weasyprint/__init__.pyi index 058279a7e405..f90f8049e63e 100644 --- a/stubs/weasyprint/weasyprint/__init__.pyi +++ b/stubs/weasyprint/weasyprint/__init__.pyi @@ -67,10 +67,10 @@ class HTML: etree_element: Element # undocumented def __init__( self, - guess: str | Path | IO | None = None, + guess: str | Path | IO[str | bytes] | None = None, filename: str | Path | None = None, url: str | None = None, - file_obj: IO | None = None, + file_obj: IO[str | bytes] | None = None, string: str | None = None, encoding: str | None = None, base_url: str | Path | None = None, @@ -86,7 +86,7 @@ class HTML: ) -> Document: ... def write_pdf( self, - target: str | Path | IO | None = None, + target: str | Path | IO[str | bytes] | None = None, zoom: float = 1, finisher: Callable[[Document, _PDF], Any] | None = None, font_config: FontConfiguration | None = None, @@ -102,10 +102,10 @@ class CSS: layers: list[str] # undocumented def __init__( self, - guess: str | Path | IO | None = None, + guess: str | Path | IO[str | bytes] | None = None, filename: str | Path | None = None, url: str | None = None, - file_obj: IO | None = None, + file_obj: IO[str | bytes] | None = None, string: str | None = None, encoding: str | None = None, base_url: str | Path | None = None, @@ -122,7 +122,7 @@ class CSS: ) -> None: ... class Attachment: - source: tuple[IO, str, str | None, str | None] # undocumented + source: tuple[IO[str | bytes], str, str | None, str | None] # undocumented name: str | None # undocumented description: str | None # undocumented relationship: str # undocumented @@ -131,10 +131,10 @@ class Attachment: modified: datetime # undocumented def __init__( self, - guess: str | Path | IO | None = None, + guess: str | Path | IO[str | bytes] | None = None, filename: str | Path | None = None, url: str | None = None, - file_obj: IO | None = None, + file_obj: IO[str | bytes] | None = None, string: str | None = None, base_url: str | Path | None = None, url_fetcher: URLFetcher | None = None, From b59e392b88eb01def0d0d168033bd1af78f3f463 Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 19:45:56 +0200 Subject: [PATCH 34/56] Avoid mentioning CounterName We don't know what that is anyway diff --git c/stubs/weasyprint/weasyprint/css/counters.pyi i/stubs/weasyprint/weasyprint/css/counters.pyi index 307d81059..dd7578685 100644 --- c/stubs/weasyprint/weasyprint/css/counters.pyi +++ i/stubs/weasyprint/weasyprint/css/counters.pyi @@ -1,13 +1,10 @@ from _typeshed import Incomplete -from typing import TypeAlias def symbol(string_or_url) -> str: ... def parse_counter_style_name(tokens, counter_style): ... -CounterName: TypeAlias = ... - -class CounterStyle(dict[CounterName, Incomplete]): - def resolve_counter(self, counter_name: CounterName, previous_types=None): ... +class CounterStyle(dict[Incomplete, Incomplete]): + def resolve_counter(self, counter_name, previous_types=None): ... def render_value(self, counter_value, counter_name=None, counter=None, previous_types=None): ... - def render_marker(self, counter_name: CounterName, counter_value): ... + def render_marker(self, counter_name, counter_value): ... def copy(self) -> CounterStyle: ... --- stubs/weasyprint/weasyprint/css/counters.pyi | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/stubs/weasyprint/weasyprint/css/counters.pyi b/stubs/weasyprint/weasyprint/css/counters.pyi index 307d8105978e..dd75786852ec 100644 --- a/stubs/weasyprint/weasyprint/css/counters.pyi +++ b/stubs/weasyprint/weasyprint/css/counters.pyi @@ -1,13 +1,10 @@ from _typeshed import Incomplete -from typing import TypeAlias def symbol(string_or_url) -> str: ... def parse_counter_style_name(tokens, counter_style): ... -CounterName: TypeAlias = ... - -class CounterStyle(dict[CounterName, Incomplete]): - def resolve_counter(self, counter_name: CounterName, previous_types=None): ... +class CounterStyle(dict[Incomplete, Incomplete]): + def resolve_counter(self, counter_name, previous_types=None): ... def render_value(self, counter_value, counter_name=None, counter=None, previous_types=None): ... - def render_marker(self, counter_name: CounterName, counter_value): ... + def render_marker(self, counter_name, counter_value): ... def copy(self) -> CounterStyle: ... From f844d0261c3c65f2a8208e1b30ba9fb22cf1ba27 Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 19:53:51 +0200 Subject: [PATCH 35/56] Try avoiding generics altogether --- stubs/weasyprint/weasyprint/__init__.pyi | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/stubs/weasyprint/weasyprint/__init__.pyi b/stubs/weasyprint/weasyprint/__init__.pyi index f90f8049e63e..bed1e6140e83 100644 --- a/stubs/weasyprint/weasyprint/__init__.pyi +++ b/stubs/weasyprint/weasyprint/__init__.pyi @@ -2,7 +2,7 @@ from _typeshed import Incomplete from collections.abc import Callable from datetime import datetime from pathlib import Path -from typing import IO, Any, TypeAlias, TypedDict +from typing import TextIO, BinaryIO, Any, TypeAlias, TypedDict from typing_extensions import Unpack from xml.etree.ElementTree import Element @@ -67,10 +67,10 @@ class HTML: etree_element: Element # undocumented def __init__( self, - guess: str | Path | IO[str | bytes] | None = None, + guess: str | Path | TextIO | BinaryIO | None = None, filename: str | Path | None = None, url: str | None = None, - file_obj: IO[str | bytes] | None = None, + file_obj: TextIO | BinaryIO | None = None, string: str | None = None, encoding: str | None = None, base_url: str | Path | None = None, @@ -86,7 +86,7 @@ class HTML: ) -> Document: ... def write_pdf( self, - target: str | Path | IO[str | bytes] | None = None, + target: str | Path | TextIO | BinaryIO | None = None, zoom: float = 1, finisher: Callable[[Document, _PDF], Any] | None = None, font_config: FontConfiguration | None = None, @@ -102,10 +102,10 @@ class CSS: layers: list[str] # undocumented def __init__( self, - guess: str | Path | IO[str | bytes] | None = None, + guess: str | Path | TextIO | BinaryIO | None = None, filename: str | Path | None = None, url: str | None = None, - file_obj: IO[str | bytes] | None = None, + file_obj: TextIO | BinaryIO | None = None, string: str | None = None, encoding: str | None = None, base_url: str | Path | None = None, @@ -122,7 +122,7 @@ class CSS: ) -> None: ... class Attachment: - source: tuple[IO[str | bytes], str, str | None, str | None] # undocumented + source: tuple[TextIO | BinaryIO, str, str | None, str | None] # undocumented name: str | None # undocumented description: str | None # undocumented relationship: str # undocumented @@ -131,10 +131,10 @@ class Attachment: modified: datetime # undocumented def __init__( self, - guess: str | Path | IO[str | bytes] | None = None, + guess: str | Path | TextIO | BinaryIO | None = None, filename: str | Path | None = None, url: str | None = None, - file_obj: IO[str | bytes] | None = None, + file_obj: TextIO | BinaryIO | None = None, string: str | None = None, base_url: str | Path | None = None, url_fetcher: URLFetcher | None = None, From 2d885d1e0e807435bcdecc9c60475994ca93429d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 Jul 2026 17:56:09 +0000 Subject: [PATCH 36/56] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/weasyprint/weasyprint/__init__.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/weasyprint/weasyprint/__init__.pyi b/stubs/weasyprint/weasyprint/__init__.pyi index bed1e6140e83..a672d30b0d93 100644 --- a/stubs/weasyprint/weasyprint/__init__.pyi +++ b/stubs/weasyprint/weasyprint/__init__.pyi @@ -2,7 +2,7 @@ from _typeshed import Incomplete from collections.abc import Callable from datetime import datetime from pathlib import Path -from typing import TextIO, BinaryIO, Any, TypeAlias, TypedDict +from typing import Any, BinaryIO, TextIO, TypeAlias, TypedDict from typing_extensions import Unpack from xml.etree.ElementTree import Element From 990134b34a6a27461a03e84a6113ccc9bf0ab10c Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 22:56:18 +0200 Subject: [PATCH 37/56] Revert "Delete files which we won't need type annotations for" This reverts commit 190b8a627d2d7116bf5a69ea50956520fab8691d. # Conflicts: # stubs/weasyprint/weasyprint/css/counters.pyi --- stubs/weasyprint/weasyprint/anchors.pyi | 3 + .../weasyprint/css/computed_values.pyi | 55 ++++ stubs/weasyprint/weasyprint/css/functions.pyi | 15 ++ .../weasyprint/css/media_queries.pyi | 2 + .../weasyprint/weasyprint/css/properties.pyi | 13 + stubs/weasyprint/weasyprint/css/targets.pyi | 35 +++ stubs/weasyprint/weasyprint/css/tokens.pyi | 55 ++++ stubs/weasyprint/weasyprint/css/units.pyi | 14 + .../weasyprint/css/validation/__init__.pyi | 8 + .../weasyprint/css/validation/descriptors.pyi | 49 ++++ .../weasyprint/css/validation/expanders.pyi | 47 ++++ .../weasyprint/css/validation/properties.pyi | 249 ++++++++++++++++++ stubs/weasyprint/weasyprint/draw/__init__.pyi | 11 + stubs/weasyprint/weasyprint/draw/border.pyi | 14 + stubs/weasyprint/weasyprint/draw/color.pyi | 4 + stubs/weasyprint/weasyprint/draw/text.pyi | 4 + stubs/weasyprint/weasyprint/html.pyi | 43 +++ stubs/weasyprint/weasyprint/images.pyi | 66 +++++ .../weasyprint/weasyprint/layout/__init__.pyi | 51 ++++ .../weasyprint/weasyprint/layout/absolute.pyi | 17 ++ .../weasyprint/layout/background.pyi | 22 ++ stubs/weasyprint/weasyprint/layout/block.pyi | 70 +++++ stubs/weasyprint/weasyprint/layout/column.pyi | 13 + stubs/weasyprint/weasyprint/layout/flex.pyi | 5 + stubs/weasyprint/weasyprint/layout/float.pyi | 8 + stubs/weasyprint/weasyprint/layout/grid.pyi | 1 + stubs/weasyprint/weasyprint/layout/inline.pyi | 80 ++++++ stubs/weasyprint/weasyprint/layout/leader.pyi | 2 + .../weasyprint/weasyprint/layout/min_max.pyi | 2 + stubs/weasyprint/weasyprint/layout/page.pyi | 67 +++++ .../weasyprint/weasyprint/layout/percent.pyi | 6 + .../weasyprint/layout/preferred.pyi | 27 ++ .../weasyprint/weasyprint/layout/replaced.pyi | 18 ++ stubs/weasyprint/weasyprint/layout/table.pyi | 23 ++ stubs/weasyprint/weasyprint/logger.pyi | 4 + stubs/weasyprint/weasyprint/matrix.pyi | 10 + stubs/weasyprint/weasyprint/pdf/__init__.pyi | 5 + stubs/weasyprint/weasyprint/pdf/anchors.pyi | 11 + stubs/weasyprint/weasyprint/pdf/debug.pyi | 5 + stubs/weasyprint/weasyprint/pdf/fonts.pyi | 38 +++ stubs/weasyprint/weasyprint/pdf/metadata.pyi | 32 +++ stubs/weasyprint/weasyprint/pdf/pdfa.pyi | 5 + stubs/weasyprint/weasyprint/pdf/pdfua.pyi | 5 + stubs/weasyprint/weasyprint/pdf/pdfx.pyi | 5 + stubs/weasyprint/weasyprint/pdf/stream.pyi | 43 +++ stubs/weasyprint/weasyprint/pdf/tags.pyi | 1 + stubs/weasyprint/weasyprint/stacking.pyi | 17 ++ stubs/weasyprint/weasyprint/svg/__init__.pyi | 86 ++++++ .../weasyprint/svg/bounding_box.pyi | 18 ++ stubs/weasyprint/weasyprint/svg/css.pyi | 6 + stubs/weasyprint/weasyprint/svg/defs.pyi | 9 + stubs/weasyprint/weasyprint/svg/images.pyi | 2 + stubs/weasyprint/weasyprint/svg/path.pyi | 3 + stubs/weasyprint/weasyprint/svg/shapes.pyi | 6 + stubs/weasyprint/weasyprint/svg/text.pyi | 12 + stubs/weasyprint/weasyprint/svg/utils.pyi | 11 + 56 files changed, 1433 insertions(+) create mode 100644 stubs/weasyprint/weasyprint/anchors.pyi create mode 100644 stubs/weasyprint/weasyprint/css/computed_values.pyi create mode 100644 stubs/weasyprint/weasyprint/css/functions.pyi create mode 100644 stubs/weasyprint/weasyprint/css/media_queries.pyi create mode 100644 stubs/weasyprint/weasyprint/css/properties.pyi create mode 100644 stubs/weasyprint/weasyprint/css/targets.pyi create mode 100644 stubs/weasyprint/weasyprint/css/tokens.pyi create mode 100644 stubs/weasyprint/weasyprint/css/units.pyi create mode 100644 stubs/weasyprint/weasyprint/css/validation/__init__.pyi create mode 100644 stubs/weasyprint/weasyprint/css/validation/descriptors.pyi create mode 100644 stubs/weasyprint/weasyprint/css/validation/expanders.pyi create mode 100644 stubs/weasyprint/weasyprint/css/validation/properties.pyi create mode 100644 stubs/weasyprint/weasyprint/draw/__init__.pyi create mode 100644 stubs/weasyprint/weasyprint/draw/border.pyi create mode 100644 stubs/weasyprint/weasyprint/draw/color.pyi create mode 100644 stubs/weasyprint/weasyprint/draw/text.pyi create mode 100644 stubs/weasyprint/weasyprint/html.pyi create mode 100644 stubs/weasyprint/weasyprint/images.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/__init__.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/absolute.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/background.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/block.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/column.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/flex.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/float.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/grid.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/inline.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/leader.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/min_max.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/page.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/percent.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/preferred.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/replaced.pyi create mode 100644 stubs/weasyprint/weasyprint/layout/table.pyi create mode 100644 stubs/weasyprint/weasyprint/logger.pyi create mode 100644 stubs/weasyprint/weasyprint/matrix.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/__init__.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/anchors.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/debug.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/fonts.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/metadata.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/pdfa.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/pdfua.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/pdfx.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/stream.pyi create mode 100644 stubs/weasyprint/weasyprint/pdf/tags.pyi create mode 100644 stubs/weasyprint/weasyprint/stacking.pyi create mode 100644 stubs/weasyprint/weasyprint/svg/__init__.pyi create mode 100644 stubs/weasyprint/weasyprint/svg/bounding_box.pyi create mode 100644 stubs/weasyprint/weasyprint/svg/css.pyi create mode 100644 stubs/weasyprint/weasyprint/svg/defs.pyi create mode 100644 stubs/weasyprint/weasyprint/svg/images.pyi create mode 100644 stubs/weasyprint/weasyprint/svg/path.pyi create mode 100644 stubs/weasyprint/weasyprint/svg/shapes.pyi create mode 100644 stubs/weasyprint/weasyprint/svg/text.pyi create mode 100644 stubs/weasyprint/weasyprint/svg/utils.pyi diff --git a/stubs/weasyprint/weasyprint/anchors.pyi b/stubs/weasyprint/weasyprint/anchors.pyi new file mode 100644 index 000000000000..1ea4962b7bd4 --- /dev/null +++ b/stubs/weasyprint/weasyprint/anchors.pyi @@ -0,0 +1,3 @@ +def rectangle_aabb(matrix, pos_x, pos_y, width, height): ... +def gather_anchors(box, anchors, links, bookmarks, forms, parent_matrix=None, parent_form=None) -> None: ... +def make_page_bookmark_tree(page, skipped_levels, last_by_depth, previous_level, page_number, matrix): ... diff --git a/stubs/weasyprint/weasyprint/css/computed_values.pyi b/stubs/weasyprint/weasyprint/css/computed_values.pyi new file mode 100644 index 000000000000..3afdd63f477b --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/computed_values.pyi @@ -0,0 +1,55 @@ +from _typeshed import Incomplete + +FONT_SIZE_KEYWORDS: Incomplete +BORDER_WIDTH_KEYWORDS: Incomplete +FONT_WEIGHT_RELATIVE: Incomplete +PAGE_SIZES: Incomplete +INITIAL_PAGE_SIZE: Incomplete +PHYSICAL_FUNCTIONS: Incomplete + +def register_logical(names, prefixes=("",), suffixes=("",)): ... +def physical_size(name, prefix, suffix, block, inline): ... +def physical_inset(name, prefix, suffix, block, inline): ... +def physical_radius(name, prefix, suffix, block, inline): ... + +COMPUTER_FUNCTIONS: Incomplete + +def register_computer(name): ... +def compute_attr(style, values): ... +def background_image(style, name, values): ... +def image(style, name, image): ... +def color(style, name, values): ... +def compute_position(style, name, values): ... +def length_or_percentage_tuple(style, name, values): ... +def length_tuple(style, name, values): ... +def break_before_after(style, name, value): ... +def length(style, name, value, font_size=None, pixels_only: bool = False): ... +def bleed(style, name, value): ... +def pixel_length(style, name, value): ... +def background_size(style, name, values): ... +def image_orientation(style, name, values): ... +def border_width(style, name, value): ... +def border_image_slice(style, name, values): ... +def border_image_width(style, name, values): ... +def border_image_outset(style, name, values): ... +def border_image_repeat(style, name, values): ... +def length_pixels_only(style, name, value): ... +def border_radius(style, name, values): ... +def gap(style, name, value): ... +def bookmark_label(style, name, values): ... +def string_set(style, name, values): ... +def content(style, name, values): ... +def display(style, name, value): ... +def compute_float(style, name, value): ... +def font_size(style, name, value): ... +def font_weight(style, name, value): ... +def grid_template(style, name, values): ... +def grid_auto(style, name, values): ... +def line_height(style, name, value): ... +def anchor(style, name, values): ... +def link(style, name, values): ... +def lang(style, name, values): ... +def tab_size(style, name, value): ... +def transform(style, name, value): ... +def vertical_align(style, name, value): ... +def word_spacing(style, name, value): ... diff --git a/stubs/weasyprint/weasyprint/css/functions.pyi b/stubs/weasyprint/weasyprint/css/functions.pyi new file mode 100644 index 000000000000..0adba4f045c7 --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/functions.pyi @@ -0,0 +1,15 @@ +from _typeshed import Incomplete + +class Function: + name: Incomplete + arguments: Incomplete + def __init__(self, token) -> None: ... + def split_space(self): ... + def split_comma(self, single_tokens: bool = True, trailing: bool = False): ... + +def check_attr(token, allowed_type=None): ... +def check_counter(token, allowed_type=None): ... +def check_content(token): ... +def check_string_or_element(string_or_element, token): ... +def check_var(token): ... +def check_math(token): ... diff --git a/stubs/weasyprint/weasyprint/css/media_queries.pyi b/stubs/weasyprint/weasyprint/css/media_queries.pyi new file mode 100644 index 000000000000..ca443734ce87 --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/media_queries.pyi @@ -0,0 +1,2 @@ +def evaluate_media_query(query_list, device_media_type): ... +def parse_media_query(tokens): ... diff --git a/stubs/weasyprint/weasyprint/css/properties.pyi b/stubs/weasyprint/weasyprint/css/properties.pyi new file mode 100644 index 000000000000..1983a5c3405f --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/properties.pyi @@ -0,0 +1,13 @@ +from _typeshed import Incomplete +from typing import NamedTuple + +class Dimension(NamedTuple): + value: Incomplete + unit: Incomplete + +ZERO_PIXELS: Incomplete +INITIAL_VALUES: Incomplete +KNOWN_PROPERTIES: Incomplete +INHERITED: Incomplete +TABLE_WRAPPER_BOX_PROPERTIES: Incomplete +INITIAL_NOT_COMPUTED: Incomplete diff --git a/stubs/weasyprint/weasyprint/css/targets.pyi b/stubs/weasyprint/weasyprint/css/targets.pyi new file mode 100644 index 000000000000..94356f9a3ab2 --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/targets.pyi @@ -0,0 +1,35 @@ +from _typeshed import Incomplete + +class TargetLookupItem: + state: Incomplete + target_box: Incomplete + parse_again_functions: Incomplete + page_maker_index: Incomplete + cached_page_counter_values: Incomplete + def __init__(self, state: str = "pending") -> None: ... + +class CounterLookupItem: + parse_again: Incomplete + missing_counters: Incomplete + missing_target_counters: Incomplete + page_maker_index: Incomplete + pending: bool + cached_page_counter_values: Incomplete + def __init__(self, parse_again, missing_counters, missing_target_counters) -> None: ... + +def anchor_name_from_token(anchor_token): ... + +class TargetCollector: + target_lookup_items: Incomplete + counter_lookup_items: Incomplete + collecting: bool + had_pending_targets: bool + def __init__(self) -> None: ... + def collect_anchor(self, anchor_name) -> None: ... + def lookup_target(self, anchor_token, source_box, css_token, parse_again): ... + def store_target(self, anchor_name, target_counter_values, target_box) -> None: ... + def collect_missing_counters( + self, parent_box, css_token, parse_again_function, missing_counters, missing_target_counters + ) -> None: ... + def check_pending_targets(self) -> None: ... + def cache_target_page_counters(self, anchor_name, page_counter_values, page_maker_index, page_maker) -> None: ... diff --git a/stubs/weasyprint/weasyprint/css/tokens.pyi b/stubs/weasyprint/weasyprint/css/tokens.pyi new file mode 100644 index 000000000000..fae461b4ec5e --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/tokens.pyi @@ -0,0 +1,55 @@ +import abc +from _typeshed import Incomplete +from abc import ABC, abstractmethod + +ZERO_PERCENT: Incomplete +FIFTY_PERCENT: Incomplete +HUNDRED_PERCENT: Incomplete +BACKGROUND_POSITION_PERCENTAGES: Incomplete +DIRECTION_KEYWORDS: Incomplete +E: Incomplete +PI: Incomplete +PLUS_INFINITY: Incomplete +MINUS_INFINITY: Incomplete +NAN: Incomplete + +class InvalidValues(ValueError): ... +class PercentageInMath(ValueError): ... +class RelativeLengthInMath(ValueError): ... + +class Pending(ABC, metaclass=abc.ABCMeta): + tokens: Incomplete + name: Incomplete + def __init__(self, tokens, name) -> None: ... + @abstractmethod + def validate(self, tokens, wanted_key): ... + def solve(self, tokens, wanted_key): ... + +def parse_color_hint(tokens): ... +def parse_color_stop(tokens): ... +def parse_color_stops_and_hints(color_stops_hints): ... +def parse_linear_gradient_parameters(arguments): ... +def parse_2d_position(tokens): ... +def parse_position(tokens): ... +def parse_radial_gradient_parameters(arguments): ... +def split_on_comma(tokens): ... +def remove_whitespace(tokens): ... +def get_keyword(token): ... +def get_custom_ident(token): ... +def get_single_keyword(tokens): ... +def get_number(token, negative: bool = True, integer: bool = False): ... +def get_string(token): ... +def get_percentage(token, negative: bool = True): ... +def get_length(token, negative: bool = True, percentage: bool = False): ... +def get_angle(token): ... +def get_resolution(token): ... +def get_image(token, base_url): ... +def get_url(token, base_url): ... +def get_quote(token): ... +def get_target(token, base_url): ... +def get_content_list(tokens, base_url): ... +def get_content_list_token(token, base_url): ... +def single_keyword(function): ... +def single_token(function): ... +def comma_separated_list(function): ... +def tokenize(item, function=None, unit=None): ... diff --git a/stubs/weasyprint/weasyprint/css/units.pyi b/stubs/weasyprint/weasyprint/css/units.pyi new file mode 100644 index 000000000000..2e06491028ab --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/units.pyi @@ -0,0 +1,14 @@ +from _typeshed import Incomplete + +ANGLE_TO_RADIANS: Incomplete +LENGTHS_TO_PIXELS: Incomplete +RESOLUTION_TO_DPPX: Incomplete +ABSOLUTE_UNITS: Incomplete +FONT_UNITS: Incomplete +VIEWPORT_UNITS: Incomplete +RELATIVE_UNITS = FONT_UNITS | VIEWPORT_UNITS +LENGTH_UNITS = ABSOLUTE_UNITS | RELATIVE_UNITS +ANGLE_UNITS: Incomplete + +def to_pixels(value, style, property_name, font_size=None): ... +def to_radians(value): ... diff --git a/stubs/weasyprint/weasyprint/css/validation/__init__.pyi b/stubs/weasyprint/weasyprint/css/validation/__init__.pyi new file mode 100644 index 000000000000..a67563c1b071 --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/validation/__init__.pyi @@ -0,0 +1,8 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +NOT_PRINT_MEDIA: Incomplete +NESTING_SELECTOR: Incomplete +ROOT_TOKEN: Incomplete + +def preprocess_declarations(base_url, declarations, prelude=None) -> Generator[Incomplete, Incomplete]: ... diff --git a/stubs/weasyprint/weasyprint/css/validation/descriptors.pyi b/stubs/weasyprint/weasyprint/css/validation/descriptors.pyi new file mode 100644 index 000000000000..43d34c46c0ea --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/validation/descriptors.pyi @@ -0,0 +1,49 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +from ..tokens import comma_separated_list, single_keyword, single_token + +DESCRIPTORS: Incomplete +NOT_PRINT_MEDIA: Incomplete + +class NoneFakeToken: + type: str + lower_value: str + +class NormalFakeToken: + type: str + lower_value: str + +def preprocess_descriptors(rule, base_url, descriptors) -> Generator[Incomplete]: ... +def descriptor(rule, descriptor_name=None, wants_base_url: bool = False): ... +def expand_font_variant(tokens) -> Generator[Incomplete]: ... +def font_family(tokens, allow_spaces: bool = False): ... +@comma_separated_list +def src(tokens, base_url): ... +@single_keyword +def font_style(keyword): ... +@single_token +def font_weight(token): ... +@single_keyword +def font_stretch(keyword): ... +def font_feature_settings(tokens): ... +def font_variant(tokens): ... +@comma_separated_list +@single_token +def unicode_range(token): ... +def system(tokens): ... +def negative(tokens, base_url): ... +def prefix_suffix(tokens, base_url): ... +@comma_separated_list +def range(tokens): ... +def pad(tokens, base_url): ... +@single_token +def fallback(token): ... +def symbols(tokens, base_url): ... +def additive_symbols(tokens, base_url): ... +@single_token +def color_profile_src(token, base_url): ... +@single_keyword +def rendering_intent(keyword): ... +@comma_separated_list +def components(tokens): ... diff --git a/stubs/weasyprint/weasyprint/css/validation/expanders.pyi b/stubs/weasyprint/weasyprint/css/validation/expanders.pyi new file mode 100644 index 000000000000..4b063d8f2b80 --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/validation/expanders.pyi @@ -0,0 +1,47 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +from ..tokens import Pending + +EXPANDERS: Incomplete + +class PendingExpander(Pending): + validator: Incomplete + def __init__(self, tokens, validator) -> None: ... + def validate(self, tokens, wanted_key): ... + +def expander(property_name): ... +def generic_expander(*expanded_names, **kwargs): ... +def expand_two_logical_sides(tokens, name, base_url) -> Generator[Incomplete, Incomplete]: ... +def expand_four_sides(tokens, name, base_url) -> Generator[Incomplete, Incomplete]: ... +def border_radius(tokens, name, base_url) -> Generator[Incomplete]: ... +def expand_list_style(tokens, name, base_url) -> Generator[Incomplete]: ... +def expand_border(tokens, name, base_url) -> Generator[Incomplete, Incomplete]: ... +def expand_logical_border(tokens, name, base_url) -> Generator[Incomplete, Incomplete]: ... +def expand_border_side(tokens, name) -> Generator[Incomplete]: ... +def expand_border_image(tokens, name, base_url) -> Generator[Incomplete]: ... +def expand_mask_border(tokens, name, base_url) -> Generator[Incomplete]: ... +def expand_background(tokens, name, base_url) -> Generator[Incomplete, Incomplete, Incomplete]: ... +def expand_text_decoration(tokens, name) -> Generator[Incomplete]: ... +def expand_page_break_before_after(tokens, name) -> Generator[Incomplete]: ... +def expand_page_break_after(tokens, name): ... +def expand_page_break_before(tokens, name): ... +def expand_page_break_inside(tokens, name) -> Generator[Incomplete]: ... +def expand_columns(tokens, name) -> Generator[Incomplete]: ... +def font_variant(tokens, name): ... +def expand_font(tokens, name) -> Generator[Incomplete]: ... +def expand_word_wrap(tokens, name) -> Generator[Incomplete]: ... +def expand_flex(tokens, name) -> Generator[Incomplete]: ... +def expand_flex_flow(tokens, name) -> Generator[Incomplete]: ... +def expand_grid_template(tokens, name) -> Generator[Incomplete, Incomplete]: ... +def expand_grid(tokens, name) -> Generator[Incomplete]: ... +def expand_grid_column_row(tokens, name) -> Generator[Incomplete]: ... +def expand_grid_area(tokens, name) -> Generator[Incomplete]: ... +def expand_gap(tokens, name) -> Generator[Incomplete]: ... +def expand_legacy_column_gap(tokens, name) -> Generator[Incomplete]: ... +def expand_legacy_row_gap(tokens, name) -> Generator[Incomplete]: ... +def expand_place_content(tokens, name) -> None: ... +def expand_place_items(tokens, name) -> None: ... +def expand_place_self(tokens, name) -> None: ... +def expand_line_clamp(tokens, name) -> Generator[Incomplete]: ... +def expand_text_align(tokens, name) -> Generator[Incomplete]: ... diff --git a/stubs/weasyprint/weasyprint/css/validation/properties.pyi b/stubs/weasyprint/weasyprint/css/validation/properties.pyi new file mode 100644 index 000000000000..beabb5cd6d5d --- /dev/null +++ b/stubs/weasyprint/weasyprint/css/validation/properties.pyi @@ -0,0 +1,249 @@ +from _typeshed import Incomplete + +from ..tokens import Pending, comma_separated_list, single_keyword, single_token + +PREFIX: str +PROPRIETARY: Incomplete +UNSTABLE: Incomplete +PROPERTIES: Incomplete + +class PendingProperty(Pending): + def validate(self, tokens, wanted_key): ... + +def property(property_name=None, proprietary: bool = False, unstable: bool = False, wants_base_url: bool = False): ... +def validate_non_shorthand(tokens, name, base_url=None, required: bool = False): ... +@comma_separated_list +@single_keyword +def background_attachment(keyword): ... +@single_token +def other_colors(token): ... +@single_token +def outline_color(token): ... +@single_keyword +def border_collapse(keyword): ... +@single_keyword +def empty_cells(keyword): ... +@single_token +def color(token): ... +@comma_separated_list +@single_token +def background_image(token, base_url): ... +@single_token +def list_style_image(token, base_url): ... +def transform_origin(tokens): ... +@comma_separated_list +def background_position(tokens): ... +@comma_separated_list +def object_position(tokens): ... +@comma_separated_list +def background_repeat(tokens): ... +@comma_separated_list +def background_size(tokens): ... +@comma_separated_list +@single_keyword +def box(keyword): ... +def border_spacing(tokens): ... +def border_corner_radius(tokens): ... +@single_keyword +def border_style(keyword): ... +@single_keyword +def break_before_after(keyword): ... +@single_keyword +def break_inside(keyword): ... +@single_keyword +def box_decoration_break(keyword): ... +@single_token +def block_ellipsis(token): ... +@single_keyword +def continue_(keyword): ... +@single_token +def max_lines(token): ... +@single_keyword +def margin_break(keyword): ... +@single_token +def page(token): ... +@single_token +def bleed(token): ... +def marks(tokens): ... +@single_keyword +def outline_style(keyword): ... +@single_token +def border_width(token): ... +@single_token +def border_image_source(token, base_url): ... +def border_image_slice(tokens): ... +def border_image_width(tokens): ... +def border_image_outset(tokens): ... +def border_image_repeat(tokens): ... +@single_keyword +def mask_border_mode(keyword): ... +@single_token +def column_width(token): ... +@single_keyword +def column_span(keyword): ... +@single_keyword +def box_sizing(keyword): ... +@single_keyword +def caption_side(keyword): ... +@single_keyword +def clear(keyword): ... +@single_token +def clip(token): ... +def content(tokens, base_url): ... +def counter_increment(tokens): ... +def counter_reset(tokens): ... +def counter_set(tokens): ... +def counter(tokens, default_integer): ... +@single_token +def lenght_precentage_or_auto(token): ... +@single_token +def width_height(token): ... +@single_token +def gap(token): ... +@single_keyword +def column_fill(keyword): ... +@single_keyword +def direction(keyword): ... +def display(tokens): ... +@single_keyword +def float_(keyword): ... +@comma_separated_list +def font_family(tokens): ... +@single_keyword +def font_kerning(keyword): ... +@single_token +def font_language_override(token): ... +def font_variant_ligatures(tokens): ... +@single_keyword +def font_variant_position(keyword): ... +@single_keyword +def font_variant_caps(keyword): ... +def font_variant_numeric(tokens): ... +def font_feature_settings(tokens): ... +@single_keyword +def font_variant_alternates(keyword): ... +def font_variant_east_asian(tokens): ... +def font_variation_settings(tokens): ... +@single_token +def font_size(token): ... +@single_keyword +def font_style(keyword): ... +@single_keyword +def font_stretch(keyword): ... +@single_token +def font_weight(token): ... +@single_keyword +def object_fit(keyword): ... +@single_token +def image_resolution(token): ... +@single_token +def spacing(token): ... +@single_token +def outline_offset(token): ... +@single_token +def line_height(token): ... +@single_keyword +def list_style_position(keyword): ... +@single_token +def list_style_type(token): ... +@single_token +def min_width_height(token): ... +@single_token +def length_or_precentage(token): ... +@single_token +def max_width_height(token): ... +@single_token +def opacity(token): ... +@single_token +def z_index(token): ... +@single_token +def orphans_widows(token): ... +@single_token +def column_count(token): ... +@single_keyword +def overflow(keyword): ... +@single_keyword +def text_overflow(keyword): ... +@single_token +def position(token): ... +def quotes(tokens): ... +@single_keyword +def table_layout(keyword): ... +@single_keyword +def text_align_all(keyword): ... +@single_keyword +def text_align_last(keyword): ... +def text_decoration_line(tokens): ... +@single_keyword +def text_decoration_style(keyword): ... +@single_token +def text_decoration_thickness(token): ... +@single_token +def text_indent(token): ... +@single_keyword +def text_transform(keyword): ... +@single_token +def vertical_align(token): ... +@single_keyword +def visibility(keyword): ... +@single_keyword +def white_space(keyword): ... +@single_keyword +def overflow_wrap(keyword): ... +@single_keyword +def word_break(keyword): ... +@single_token +def flex_basis(token): ... +@single_keyword +def flex_direction(keyword): ... +@single_token +def flex_grow_shrink(token): ... +def grid_auto(tokens): ... +def grid_auto_flow(tokens): ... +def grid_template(tokens): ... +def grid_template_areas(tokens): ... +def grid_line(tokens): ... +@single_keyword +def flex_wrap(keyword): ... +def justify_content(tokens): ... +def justify_items(tokens): ... +def justify_self(tokens): ... +def align_items(tokens): ... +def align_self(tokens): ... +def align_content(tokens): ... +@single_token +def order(token): ... +@single_keyword +def image_rendering(keyword): ... +def image_orientation(tokens): ... +def size(tokens): ... +@single_token +def anchor(token): ... +@single_token +def link(token, base_url): ... +@single_token +def tab_size(token): ... +@single_token +def hyphens(token): ... +@single_token +def hyphenate_character(token): ... +@single_token +def hyphenate_limit_zone(token): ... +def hyphenate_limit_chars(tokens): ... +@single_token +def lang(token): ... +def bookmark_label(tokens, base_url): ... +@single_token +def bookmark_level(token): ... +@single_keyword +def bookmark_state(keyword): ... +@single_keyword +def footnote_display(keyword): ... +@single_keyword +def footnote_policy(keyword): ... +@comma_separated_list +def string_set(tokens, base_url): ... +def transform(tokens): ... +@single_token +def appearance(token): ... +def color_scheme(tokens): ... diff --git a/stubs/weasyprint/weasyprint/draw/__init__.pyi b/stubs/weasyprint/weasyprint/draw/__init__.pyi new file mode 100644 index 000000000000..4e1f46756edd --- /dev/null +++ b/stubs/weasyprint/weasyprint/draw/__init__.pyi @@ -0,0 +1,11 @@ +def draw_page(page, stream) -> None: ... +def draw_stacking_context(stream, stacking_context) -> None: ... +def draw_background(stream, bg, clip_box: bool = True, bleed=None, marks=()) -> None: ... +def draw_background_image(stream, layer, style) -> None: ... +def draw_table(stream, table): ... +def draw_collapsed_borders(stream, table): ... +def draw_replacedbox(stream, box) -> None: ... +def draw_inline_level( + stream, page, box, offset_x: int = 0, text_overflow: str = "clip", block_ellipsis: str = "none" +) -> None: ... +def draw_block_level(page, stream, blocks_and_cells) -> None: ... diff --git a/stubs/weasyprint/weasyprint/draw/border.pyi b/stubs/weasyprint/weasyprint/draw/border.pyi new file mode 100644 index 000000000000..4a91f968fb50 --- /dev/null +++ b/stubs/weasyprint/weasyprint/draw/border.pyi @@ -0,0 +1,14 @@ +from _typeshed import Incomplete + +SIDES: Incomplete + +def set_mask_border(stream, box) -> None: ... +def draw_column_rules(stream, box) -> None: ... +def draw_border(stream, box) -> None: ... +def draw_border_image(box, stream, image, border_slice, border_repeat, border_outset, border_width): ... +def clip_border_segment(stream, style, width, side, border_box, border_widths=None, radii=None): ... +def draw_rounded_border(stream, box, style, color) -> None: ... +def draw_rect_border(stream, box, widths, style, color) -> None: ... +def draw_line(stream, x1, y1, x2, y2, thickness, style, color, offset: int = 0) -> None: ... +def draw_outline(stream, box) -> None: ... +def rounded_box(stream, radii) -> None: ... diff --git a/stubs/weasyprint/weasyprint/draw/color.pyi b/stubs/weasyprint/weasyprint/draw/color.pyi new file mode 100644 index 000000000000..eafb78956314 --- /dev/null +++ b/stubs/weasyprint/weasyprint/draw/color.pyi @@ -0,0 +1,4 @@ +def get_color(style, key): ... +def darken(color): ... +def lighten(color): ... +def styled_color(style, color, side): ... diff --git a/stubs/weasyprint/weasyprint/draw/text.pyi b/stubs/weasyprint/weasyprint/draw/text.pyi new file mode 100644 index 000000000000..3137e41b372f --- /dev/null +++ b/stubs/weasyprint/weasyprint/draw/text.pyi @@ -0,0 +1,4 @@ +def draw_text(stream, textbox, offset_x, text_overflow, block_ellipsis) -> None: ... +def draw_emojis(stream, style, x, y, emojis) -> None: ... +def draw_first_line(stream, textbox, text_overflow, block_ellipsis, matrix): ... +def draw_text_decoration(stream, textbox, offset_x, offset_y, thickness, color) -> None: ... diff --git a/stubs/weasyprint/weasyprint/html.pyi b/stubs/weasyprint/weasyprint/html.pyi new file mode 100644 index 000000000000..a983a528d91b --- /dev/null +++ b/stubs/weasyprint/weasyprint/html.pyi @@ -0,0 +1,43 @@ +from _typeshed import Incomplete + +HTML5_UA_COUNTER_STYLE: Incomplete +HTML5_UA: Incomplete +HTML5_UA_FORM: Incomplete +HTML5_PH: Incomplete +HTML5_UA_STYLESHEET: Incomplete +HTML5_UA_FORM_STYLESHEET: Incomplete +HTML5_PH_STYLESHEET: Incomplete +WHITESPACE: str +SPACE_SEPARATED_TOKENS_RE: Incomplete +INTEGER_RE: Incomplete +DIMENSION_RE: Incomplete + +def parse_integer(string): ... +def parse_non_negative_integer(string): ... +def parse_dimension_value(string): ... +def parse_legacy_color(string): ... +def parse_string(string): ... +def parse_url(string): ... +def map_to_pixel_length(string): ... +def map_to_dimension_property(string): ... +def map_to_dimension_property_ignoring_zero(string): ... +def ascii_lower(string): ... +def element_has_link_type(element, link_type): ... + +HTML_HANDLERS: Incomplete + +def handle_element(element, box, get_image_from_uri, base_url): ... +def handler(tag): ... +def make_replaced_box(element, box, image): ... +def handle_img(element, box, get_image_from_uri, base_url): ... +def handle_embed(element, box, get_image_from_uri, base_url): ... +def handle_object(element, box, get_image_from_uri, base_url): ... +def handle_colgroup(element, box, _get_image_from_uri, _base_url): ... +def handle_col(element, box, _get_image_from_uri, _base_url): ... +def handle_svg(element, box, get_image_from_uri, base_url): ... +def get_html_metadata(html): ... +def strip_whitespace(string): ... + +W3C_DATE_RE: Incomplete + +def parse_w3c_date(meta_name, string): ... diff --git a/stubs/weasyprint/weasyprint/images.pyi b/stubs/weasyprint/weasyprint/images.pyi new file mode 100644 index 000000000000..05df502acf9f --- /dev/null +++ b/stubs/weasyprint/weasyprint/images.pyi @@ -0,0 +1,66 @@ +from _typeshed import Incomplete + +import pydyf + +class ImageLoadingError(ValueError): ... + +class RasterImage: + id: Incomplete + mode: Incomplete + width: Incomplete + height: Incomplete + ratio: Incomplete + optimize: Incomplete + invert_colors: Incomplete + format: str + image_data: Incomplete + def __init__( + self, pillow_image, image_id, image_data, filename=None, cache=None, orientation: str = "none", options=... + ) -> None: ... + def get_intrinsic_size(self, resolution, font_size): ... + def draw(self, stream, concrete_width, concrete_height, style) -> None: ... + def cache_image_data(self, data, filename=None, slot: str = "source"): ... + def get_x_object(self, interpolate, dpi_ratio): ... + +class LazyImage(pydyf.Object): + def __init__(self, cache, key, data) -> None: ... + @property + def data(self): ... + +class LazyLocalImage(pydyf.Object): + def __init__(self, filename) -> None: ... + @property + def data(self): ... + +class SVGImage: + def __init__(self, tree, base_url, url_fetcher, context) -> None: ... + def get_intrinsic_size(self, image_resolution, font_size): ... + def draw(self, stream, concrete_width, concrete_height, _style) -> None: ... + +def get_image_from_uri( + cache, url_fetcher, options, url, forced_mime_type=None, context=None, orientation: str = "from-image" +): ... +def rotate_pillow_image(pillow_image, orientation): ... +def process_color_stops(vector_length, positions, hints, style): ... +def normalize_stop_positions(positions): ... +def gradient_average_color(colors, positions): ... + +class Gradient: + colors: Incomplete + stop_positions: Incomplete + color_hints: Incomplete + repeating: Incomplete + def __init__(self, color_stops, repeating, color_hints) -> None: ... + def get_intrinsic_size(self, image_resolution, font_size): ... + def draw(self, stream, concrete_width, concrete_height, style) -> None: ... + def layout(self, width, height, style) -> None: ... + +class LinearGradient(Gradient): + def __init__(self, color_stops, direction, repeating, color_hints) -> None: ... + def layout(self, width, height, style): ... + +class RadialGradient(Gradient): + center: Incomplete + shape: Incomplete + def __init__(self, color_stops, shape, size, center, repeating, color_hints) -> None: ... + def layout(self, width, height, style): ... diff --git a/stubs/weasyprint/weasyprint/layout/__init__.pyi b/stubs/weasyprint/weasyprint/layout/__init__.pyi new file mode 100644 index 000000000000..8303fe9bff61 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/__init__.pyi @@ -0,0 +1,51 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def initialize_page_maker(context, root_box) -> None: ... +def layout_fixed_boxes(context, pages, containing_page) -> Generator[Incomplete]: ... +def layout_document(html, root_box, context, max_loops: int = 8) -> Generator[Incomplete]: ... + +class FakeList(list): + def append(self, item) -> None: ... + +class LayoutContext: + style_for: Incomplete + get_image_from_uri: Incomplete + font_config: Incomplete + counter_style: Incomplete + target_collector: Incomplete + footnotes: Incomplete + page_footnotes: Incomplete + current_page_footnotes: Incomplete + reported_footnotes: Incomplete + current_footnote_area: Incomplete + page_bottom: Incomplete + string_set: Incomplete + running_elements: Incomplete + current_page: Incomplete + forced_break: bool + broken_out_of_flow: Incomplete + in_column: bool + tables: Incomplete + dictionaries: Incomplete + def __init__(self, style_for, get_image_from_uri, font_config, counter_style, target_collector) -> None: ... + def overflows_page(self, bottom_space, position_y): ... + @staticmethod + def overflows(bottom, position_y): ... + + @property + def excluded_shapes(self): ... + @excluded_shapes.setter + def excluded_shapes(self, excluded_shapes) -> None: ... + + def create_block_formatting_context(self, root_box=None, new_list=None) -> None: ... + def finish_block_formatting_context(self, root_box=None) -> None: ... + def create_flex_formatting_context(self, root_box) -> None: ... + def finish_flex_formatting_context(self, root_box) -> None: ... + def add_broken_out_of_flow(self, new_box, box, containing_block, resume_at) -> None: ... + def get_string_set_for(self, page, name, keyword: str = "first"): ... + def get_running_element_for(self, page, name, keyword: str = "first"): ... + def get_string_or_element_for(self, store, page, name, keyword): ... + def layout_footnote(self, footnote): ... + def unlayout_footnote(self, footnote) -> None: ... + def report_footnote(self, footnote) -> None: ... diff --git a/stubs/weasyprint/weasyprint/layout/absolute.pyi b/stubs/weasyprint/weasyprint/layout/absolute.pyi new file mode 100644 index 000000000000..34f6a0d6c875 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/absolute.pyi @@ -0,0 +1,17 @@ +from .min_max import handle_min_max_width + +class AbsolutePlaceholder: + def __init__(self, box) -> None: ... + def set_laid_out_box(self, new_box) -> None: ... + def translate(self, dx: int = 0, dy: int = 0, ignore_floats: bool = False) -> None: ... + def copy(self): ... + def __getattr__(self, name): ... + def __setattr__(self, name, value) -> None: ... + +@handle_min_max_width +def absolute_width(box, context, cb_x, cb_y, cb_width, cb_height): ... +def absolute_height(box, context, cb_x, cb_y, cb_width, cb_height): ... +def absolute_block(context, box, containing_block, fixed_boxes, bottom_space, skip_stack, cb_x, cb_y, cb_width, cb_height): ... +def absolute_layout(context, placeholder, containing_block, fixed_boxes, bottom_space, skip_stack) -> None: ... +def absolute_box_layout(context, box, containing_block, fixed_boxes, bottom_space, skip_stack): ... +def absolute_replaced(context, box, cb_x, cb_y, cb_width, cb_height): ... diff --git a/stubs/weasyprint/weasyprint/layout/background.pyi b/stubs/weasyprint/weasyprint/layout/background.pyi new file mode 100644 index 000000000000..ae18366f3053 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/background.pyi @@ -0,0 +1,22 @@ +from _typeshed import Incomplete +from typing import NamedTuple + +class Background(NamedTuple): + color: Incomplete + layers: Incomplete + style: Incomplete + +class BackgroundLayer(NamedTuple): + image: Incomplete + size: Incomplete + position: Incomplete + repeat: Incomplete + unbounded: Incomplete + painting_area: Incomplete + positioning_area: Incomplete + clipped_boxes: Incomplete + +def box_rectangle(box, which_rectangle): ... +def layout_box_backgrounds(page, box, get_image_from_uri, layout_children: bool = True, style=None) -> None: ... +def layout_background_layer(box, page, resolution, image, size, clip, repeat, origin, position, attachment): ... +def layout_backgrounds(page, get_image_from_uri) -> None: ... diff --git a/stubs/weasyprint/weasyprint/layout/block.pyi b/stubs/weasyprint/weasyprint/layout/block.pyi new file mode 100644 index 000000000000..bd31407dcdea --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/block.pyi @@ -0,0 +1,70 @@ +def block_level_layout( + context, + box, + bottom_space, + skip_stack, + containing_block, + page_is_empty: bool = True, + absolute_boxes=None, + fixed_boxes=None, + adjoining_margins=None, + first_letter_style=None, + first_line_style=None, + discard: bool = False, + max_lines=None, +): ... +def block_level_layout_switch( + context, + box, + bottom_space, + skip_stack, + containing_block, + page_is_empty, + absolute_boxes, + fixed_boxes, + adjoining_margins, + first_letter_style, + first_line_style, + discard, + max_lines, +): ... +def block_box_layout( + context, + box, + bottom_space, + skip_stack, + containing_block, + page_is_empty, + absolute_boxes, + fixed_boxes, + adjoining_margins, + first_letter_style, + first_line_style, + discard, + max_lines, +): ... +def block_level_width(box, containing_block, with_min_max: bool = True) -> None: ... +def relative_positioning(box, containing_block) -> None: ... +def block_container_layout( + context, + box, + bottom_space, + skip_stack, + page_is_empty, + absolute_boxes, + fixed_boxes, + adjoining_margins, + first_letter_style, + first_line_style, + discard, + max_lines, +): ... +def collapse_margin(adjoining_margins): ... +def block_level_page_break(sibling_before, sibling_after): ... +def block_level_page_name(sibling_before, sibling_after): ... +def find_earlier_page_break(context, children, absolute_boxes, fixed_boxes): ... +def find_last_in_flow_child(children): ... +def reversed_enumerate(seq): ... +def remove_placeholders(context, box_list, absolute_boxes, fixed_boxes) -> None: ... +def avoid_page_break(page_break, context): ... +def force_page_break(page_break, context): ... diff --git a/stubs/weasyprint/weasyprint/layout/column.pyi b/stubs/weasyprint/weasyprint/layout/column.pyi new file mode 100644 index 000000000000..848d09c38da2 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/column.pyi @@ -0,0 +1,13 @@ +def columns_layout( + context, + box, + bottom_space, + skip_stack, + containing_block, + page_is_empty, + absolute_boxes, + fixed_boxes, + adjoining_margins, + first_letter_style, + first_line_style, +): ... diff --git a/stubs/weasyprint/weasyprint/layout/flex.pyi b/stubs/weasyprint/weasyprint/layout/flex.pyi new file mode 100644 index 000000000000..bd73d04d2091 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/flex.pyi @@ -0,0 +1,5 @@ +class FlexLine(list): ... + +def flex_layout( + context, box, bottom_space, skip_stack, containing_block, page_is_empty, absolute_boxes, fixed_boxes, discard +): ... diff --git a/stubs/weasyprint/weasyprint/layout/float.pyi b/stubs/weasyprint/weasyprint/layout/float.pyi new file mode 100644 index 000000000000..d7da34650ed5 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/float.pyi @@ -0,0 +1,8 @@ +from .min_max import handle_min_max_width + +@handle_min_max_width +def float_width(box, context, containing_block) -> None: ... +def float_layout(context, box, containing_block, absolute_boxes, fixed_boxes, bottom_space, skip_stack): ... +def find_float_position(context, box, containing_block): ... +def get_clearance(context, box, direction, collapsed_margin: int = 0): ... +def avoid_collisions(context, box, containing_block, outer: bool = True): ... diff --git a/stubs/weasyprint/weasyprint/layout/grid.pyi b/stubs/weasyprint/weasyprint/layout/grid.pyi new file mode 100644 index 000000000000..ffaaeb5cbbbd --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/grid.pyi @@ -0,0 +1 @@ +def grid_layout(context, box, bottom_space, skip_stack, containing_block, page_is_empty, absolute_boxes, fixed_boxes): ... diff --git a/stubs/weasyprint/weasyprint/layout/inline.pyi b/stubs/weasyprint/weasyprint/layout/inline.pyi new file mode 100644 index 000000000000..79da8a9c49a5 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/inline.pyi @@ -0,0 +1,80 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +from .min_max import handle_min_max_width + +def iter_line_boxes( + context, + box, + position_y, + bottom_space, + skip_stack, + containing_block, + absolute_boxes, + fixed_boxes, + first_letter_style, + first_line_style, +) -> Generator[Incomplete]: ... +def get_next_linebox( + context, + linebox, + position_y, + bottom_space, + skip_stack, + containing_block, + absolute_boxes, + fixed_boxes, + first_letter_style, + first_line_style, +): ... +def skip_first_whitespace(box, skip_stack): ... +def remove_last_whitespace(context, line) -> None: ... +def first_letter_to_box(box, skip_stack, first_letter_style): ... +def atomic_box(context, box, position_x, skip_stack, containing_block, absolute_boxes, fixed_boxes): ... +def inline_block_box_layout(context, box, position_x, skip_stack, containing_block, absolute_boxes, fixed_boxes): ... +def inline_block_baseline(box): ... +@handle_min_max_width +def inline_block_width(box, context, containing_block) -> None: ... +def split_inline_level( + context, + box, + position_x, + max_x, + bottom_space, + skip_stack, + containing_block, + absolute_boxes, + fixed_boxes, + line_placeholders, + waiting_floats, + line_children, + first_letter_style, + first_line_style, +): ... +def split_inline_box( + context, + box, + position_x, + max_x, + bottom_space, + skip_stack, + containing_block, + absolute_boxes, + fixed_boxes, + line_placeholders, + waiting_floats, + line_children, + first_letter_style, + first_line_style, +): ... +def split_text_box(context, box, available_width, skip, is_line_start: bool = True): ... +def line_box_verticality(box): ... +def translate_subtree(box, dy) -> None: ... +def aligned_subtree_verticality(box, top_bottom_subtrees, baseline_y): ... +def inline_box_verticality(box, top_bottom_subtrees, baseline_y): ... +def text_align(context, line, available_width, last): ... +def justify_line(context, line, extra_width) -> None: ... +def count_expandable_spaces(box): ... +def add_word_spacing(context, box, justification_spacing, x_advance): ... +def is_phantom_linebox(linebox): ... +def can_break_inside(box): ... diff --git a/stubs/weasyprint/weasyprint/layout/leader.pyi b/stubs/weasyprint/weasyprint/layout/leader.pyi new file mode 100644 index 000000000000..d976c641a8d0 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/leader.pyi @@ -0,0 +1,2 @@ +def leader_index(box): ... +def handle_leader(context, line, containing_block) -> None: ... diff --git a/stubs/weasyprint/weasyprint/layout/min_max.pyi b/stubs/weasyprint/weasyprint/layout/min_max.pyi new file mode 100644 index 000000000000..8bba11f54c73 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/min_max.pyi @@ -0,0 +1,2 @@ +def handle_min_max_width(function): ... +def handle_min_max_height(function): ... diff --git a/stubs/weasyprint/weasyprint/layout/page.pyi b/stubs/weasyprint/weasyprint/layout/page.pyi new file mode 100644 index 000000000000..58f1e258b8a2 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/page.pyi @@ -0,0 +1,67 @@ +from _typeshed import Incomplete +from collections.abc import Generator +from typing import NamedTuple + +from .min_max import handle_min_max_height, handle_min_max_width + +class PageType(NamedTuple): + side: Incomplete + blank: Incomplete + name: Incomplete + index: Incomplete + groups: Incomplete + +class OrientedBox: + @property + def sugar(self): ... + @property + def outer(self): ... + inner: Incomplete + @outer.setter + def outer(self, new_outer_width) -> None: ... + @property + def outer_min_content_size(self): ... + @property + def outer_max_content_size(self): ... + +class VerticalBox(OrientedBox): + context: Incomplete + box: Incomplete + inner: Incomplete + margin_a: Incomplete + margin_b: Incomplete + padding_plus_border: Incomplete + def __init__(self, context, box) -> None: ... + def restore_box_attributes(self) -> None: ... + @property + def min_content_size(self): ... + @property + def max_content_size(self): ... + +class HorizontalBox(OrientedBox): + context: Incomplete + box: Incomplete + inner: Incomplete + margin_a: Incomplete + margin_b: Incomplete + padding_plus_border: Incomplete + def __init__(self, context, box) -> None: ... + def restore_box_attributes(self) -> None: ... + @property + def min_content_size(self): ... + @property + def max_content_size(self): ... + +def compute_fixed_dimension(context, box, outer, vertical, top_or_left) -> None: ... +def compute_variable_dimension(context, side_boxes, vertical, available_size) -> None: ... +def make_margin_boxes(context, page, state) -> Generator[Incomplete, None, Incomplete]: ... +def margin_box_content_layout(context, page, box): ... +def page_width_or_height(box, containing_block_size) -> None: ... +@handle_min_max_width +def page_width(box, context, containing_block_width) -> None: ... +@handle_min_max_height +def page_height(box, context, containing_block_height) -> None: ... +def make_page(context, root_box, page_type, resume_at, page_number, page_state): ... +def set_page_type_computed_styles(page_type, html, style_for) -> None: ... +def remake_page(index, context, root_box, html): ... +def make_all_pages(context, root_box, html, pages) -> Generator[Incomplete]: ... diff --git a/stubs/weasyprint/weasyprint/layout/percent.pyi b/stubs/weasyprint/weasyprint/layout/percent.pyi new file mode 100644 index 000000000000..bc30b37aee7f --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/percent.pyi @@ -0,0 +1,6 @@ +def percentage(value, computed, refer_to): ... +def resolve_one_percentage(box, property_name, refer_to) -> None: ... +def resolve_position_percentages(box, containing_block) -> None: ... +def resolve_percentages(box, containing_block) -> None: ... +def resolve_radii_percentages(box) -> None: ... +def adjust_box_sizing(box, axis) -> None: ... diff --git a/stubs/weasyprint/weasyprint/layout/preferred.pyi b/stubs/weasyprint/weasyprint/layout/preferred.pyi new file mode 100644 index 000000000000..06b5768980be --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/preferred.pyi @@ -0,0 +1,27 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def shrink_to_fit(context, box, available_content_width): ... +def min_content_width(context, box, outer: bool = True): ... +def max_content_width(context, box, outer: bool = True): ... +def min_max(box, width): ... +def margin_width(box, width, left: bool = True, right: bool = True): ... +def adjust(box, outer, width, left: bool = True, right: bool = True): ... +def block_min_content_width(context, box, outer: bool = True): ... +def block_max_content_width(context, box, outer: bool = True): ... +def inline_min_content_width( + context, box, outer: bool = True, skip_stack=None, first_line: bool = False, is_line_start: bool = False +): ... +def inline_max_content_width(context, box, outer: bool = True, is_line_start: bool = False): ... +def column_group_content_width(context, box): ... +def table_cell_min_content_width(context, box, outer): ... +def table_cell_min_max_content_width(context, box, outer: bool = True): ... +def inline_line_widths( + context, box, outer, is_line_start, minimum, skip_stack=None, first_line: bool = False +) -> Generator[Incomplete]: ... +def table_and_columns_preferred_widths(context, box, outer: bool = True): ... +def replaced_min_content_width(box, outer: bool = True): ... +def replaced_max_content_width(box, outer: bool = True): ... +def flex_min_content_width(context, box, outer: bool = True): ... +def flex_max_content_width(context, box, outer: bool = True): ... +def trailing_whitespace_size(context, box): ... diff --git a/stubs/weasyprint/weasyprint/layout/replaced.pyi b/stubs/weasyprint/weasyprint/layout/replaced.pyi new file mode 100644 index 000000000000..6b16f9a649c3 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/replaced.pyi @@ -0,0 +1,18 @@ +from .min_max import handle_min_max_height, handle_min_max_width + +def default_image_sizing( + intrinsic_width, intrinsic_height, intrinsic_ratio, specified_width, specified_height, default_width, default_height +): ... +def contain_constraint_image_sizing(constraint_width, constraint_height, intrinsic_ratio): ... +def cover_constraint_image_sizing(constraint_width, constraint_height, intrinsic_ratio): ... +def replacedbox_layout(box): ... +@handle_min_max_width +def replaced_box_width(box, containing_block) -> None: ... +@handle_min_max_height +def replaced_box_height(box) -> None: ... +def inline_replaced_box_layout(box, containing_block) -> None: ... +def inline_replaced_box_width_height(box, containing_block) -> None: ... +def min_max_auto_replaced(box) -> None: ... +def block_replaced_box_layout(context, box, containing_block): ... +@handle_min_max_width +def block_replaced_width(box, containing_block) -> None: ... diff --git a/stubs/weasyprint/weasyprint/layout/table.pyi b/stubs/weasyprint/weasyprint/layout/table.pyi new file mode 100644 index 000000000000..bfc8487322b7 --- /dev/null +++ b/stubs/weasyprint/weasyprint/layout/table.pyi @@ -0,0 +1,23 @@ +from _typeshed import Incomplete + +def table_layout(context, table, bottom_space, skip_stack, containing_block, page_is_empty, absolute_boxes, fixed_boxes): ... +def add_top_padding(box, extra_padding) -> None: ... +def fixed_table_layout(box) -> None: ... +def auto_table_layout(context, box, containing_block) -> None: ... +def table_wrapper_width(context, wrapper, containing_block) -> None: ... +def cell_baseline(cell): ... +def find_in_flow_baseline(box, last: bool = False, baseline_types=...): ... +def distribute_excess_width( + context, + grid, + excess_width, + column_widths, + constrainedness, + column_intrinsic_percentages, + column_max_content_widths, + column_slice=..., +) -> None: ... + +TRANSPARENT: Incomplete + +def collapse_table_borders(table, grid_width, grid_height): ... diff --git a/stubs/weasyprint/weasyprint/logger.pyi b/stubs/weasyprint/weasyprint/logger.pyi new file mode 100644 index 000000000000..29097aea7d91 --- /dev/null +++ b/stubs/weasyprint/weasyprint/logger.pyi @@ -0,0 +1,4 @@ +from _typeshed import Incomplete + +LOGGER: Incomplete +PROGRESS_LOGGER: Incomplete diff --git a/stubs/weasyprint/weasyprint/matrix.pyi b/stubs/weasyprint/weasyprint/matrix.pyi new file mode 100644 index 000000000000..603ceb1a3d6b --- /dev/null +++ b/stubs/weasyprint/weasyprint/matrix.pyi @@ -0,0 +1,10 @@ +class Matrix(list): + def __init__(self, a: int = 1, b: int = 0, c: int = 0, d: int = 1, e: int = 0, f: int = 0, matrix=None) -> None: ... + def __matmul__(self, other): ... + @property + def invert(self): ... + @property + def determinant(self): ... + def transform_point(self, x, y): ... + @property + def values(self): ... diff --git a/stubs/weasyprint/weasyprint/pdf/__init__.pyi b/stubs/weasyprint/weasyprint/pdf/__init__.pyi new file mode 100644 index 000000000000..a6613c97e5f3 --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/__init__.pyi @@ -0,0 +1,5 @@ +from _typeshed import Incomplete + +VARIANTS: Incomplete + +def generate_pdf(document, target, zoom, **options): ... diff --git a/stubs/weasyprint/weasyprint/pdf/anchors.pyi b/stubs/weasyprint/weasyprint/pdf/anchors.pyi new file mode 100644 index 000000000000..e5c014d888ee --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/anchors.pyi @@ -0,0 +1,11 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +MIMETYPES: Incomplete + +def add_links(links_and_anchors, matrix, pdf, page, names, tags) -> None: ... +def add_outlines(pdf, bookmarks, parent=None): ... +def add_forms(forms, matrix, pdf, page, resources, stream, font_map) -> None: ... +def add_annotations(links, matrix, document, pdf, page, annot_files, compress) -> None: ... +def write_pdf_attachment(pdf, attachment, compress): ... +def resolve_links(pages) -> Generator[Incomplete]: ... diff --git a/stubs/weasyprint/weasyprint/pdf/debug.pyi b/stubs/weasyprint/weasyprint/pdf/debug.pyi new file mode 100644 index 000000000000..7472ba8d9362 --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/debug.pyi @@ -0,0 +1,5 @@ +from _typeshed import Incomplete + +def debug(pdf, metadata, document, page_streams, attachments, compress) -> None: ... + +VARIANTS: Incomplete diff --git a/stubs/weasyprint/weasyprint/pdf/fonts.pyi b/stubs/weasyprint/weasyprint/pdf/fonts.pyi new file mode 100644 index 000000000000..23ddfe40ac05 --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/fonts.pyi @@ -0,0 +1,38 @@ +from _typeshed import Incomplete + +class Font: + hb_font: Incomplete + hb_face: Incomplete + file_content: Incomplete + index: Incomplete + font_size: Incomplete + style: Incomplete + family: Incomplete + variations: Incomplete + weight: Incomplete + hash: Incomplete + name: Incomplete + ascent: Incomplete + descent: Incomplete + tables: Incomplete + bitmap: bool + italic_angle: int + upem: Incomplete + png: Incomplete + svg: Incomplete + glyph_count: Incomplete + stemv: int + stemh: int + widths: Incomplete + to_unicode: Incomplete + missing: Incomplete + used_in_forms: bool + flags: Incomplete + def __init__(self, pango_font, description, font_size) -> None: ... + def get_unused_glyph_id(self, codepoint): ... + def clean(self, to_unicode, hinting) -> None: ... + @property + def type(self): ... + def subset(self, to_unicode, hinting) -> None: ... + +def build_fonts_dictionary(pdf, fonts, compress, subset, options): ... diff --git a/stubs/weasyprint/weasyprint/pdf/metadata.pyi b/stubs/weasyprint/weasyprint/pdf/metadata.pyi new file mode 100644 index 000000000000..d21b9b9cc779 --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/metadata.pyi @@ -0,0 +1,32 @@ +from _typeshed import Incomplete + +NS: Incomplete + +class DocumentMetadata: + title: Incomplete + authors: Incomplete + description: Incomplete + keywords: Incomplete + generator: Incomplete + created: Incomplete + modified: Incomplete + attachments: Incomplete + lang: Incomplete + custom: Incomplete + xmp_metadata: Incomplete + def __init__( + self, + title=None, + authors=None, + description=None, + keywords=None, + generator=None, + created=None, + modified=None, + attachments=None, + lang=None, + custom=None, + xmp_metadata=None, + ) -> None: ... + def include_in_pdf(self, pdf, variant, version, conformance, compress) -> None: ... + def generate_rdf_metadata(self, variant, version, conformance): ... diff --git a/stubs/weasyprint/weasyprint/pdf/pdfa.pyi b/stubs/weasyprint/weasyprint/pdf/pdfa.pyi new file mode 100644 index 000000000000..d0108cd87f44 --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/pdfa.pyi @@ -0,0 +1,5 @@ +from _typeshed import Incomplete + +def pdfa(pdf, document, page_streams, attachments, compress, version, variant) -> None: ... + +VARIANTS: Incomplete diff --git a/stubs/weasyprint/weasyprint/pdf/pdfua.pyi b/stubs/weasyprint/weasyprint/pdf/pdfua.pyi new file mode 100644 index 000000000000..c55404defad9 --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/pdfua.pyi @@ -0,0 +1,5 @@ +from _typeshed import Incomplete + +def pdfua(pdf, document, page_streams, attachments, compress, version) -> None: ... + +VARIANTS: Incomplete diff --git a/stubs/weasyprint/weasyprint/pdf/pdfx.pyi b/stubs/weasyprint/weasyprint/pdf/pdfx.pyi new file mode 100644 index 000000000000..3e001eef1cbf --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/pdfx.pyi @@ -0,0 +1,5 @@ +from _typeshed import Incomplete + +def pdfx(pdf, document, page_streams, attachments, compress, version, variant) -> None: ... + +VARIANTS: Incomplete diff --git a/stubs/weasyprint/weasyprint/pdf/stream.pyi b/stubs/weasyprint/weasyprint/pdf/stream.pyi new file mode 100644 index 000000000000..4ad92e2c2cf3 --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/stream.pyi @@ -0,0 +1,43 @@ +from _typeshed import Incomplete +from collections.abc import Generator +from contextlib import contextmanager + +import pydyf + +class Stream(pydyf.Stream): + page_rectangle: Incomplete + length: Incomplete + ink_rect: Incomplete + logical_rect: Incomplete + def __init__( + self, fonts, page_rectangle, resources, images, tags, color_profiles, output_intent, *args, **kwargs + ) -> None: ... + def clone(self, **kwargs): ... + @property + def ctm(self): ... + def push_state(self) -> None: ... + def pop_state(self) -> None: ... + def transform(self, a: int = 1, b: int = 0, c: int = 0, d: int = 1, e: int = 0, f: int = 0) -> None: ... + def begin_text(self) -> None: ... + def end_text(self) -> None: ... + def set_color(self, color, stroke: bool = False) -> None: ... + def set_font_size(self, font, size) -> None: ... + def set_state(self, state) -> None: ... + def set_alpha(self, alpha, stroke: bool = False, fill=None) -> None: ... + def set_alpha_state(self, x, y, width, height, mode: str = "luminosity"): ... + def set_blend_mode(self, mode) -> None: ... + def add_font(self, pango_font): ... + def add_group(self, x, y, width, height): ... + def add_image(self, image, interpolate, ratio): ... + def add_pattern(self, x, y, width, height, repeat_width, repeat_height, matrix): ... + def add_shading(self, shading_type, domain, coords, extend, function, color_space=None): ... + @contextmanager + def stacked(self) -> Generator[None]: ... + @contextmanager + def marked(self, box, tag) -> Generator[None]: ... + @contextmanager + def artifact(self) -> Generator[None]: ... + @staticmethod + def create_interpolation_function(domain, c0, c1, n): ... + @staticmethod + def create_stitching_function(domain, encode, bounds, sub_functions): ... diff --git a/stubs/weasyprint/weasyprint/pdf/tags.pyi b/stubs/weasyprint/weasyprint/pdf/tags.pyi new file mode 100644 index 000000000000..57f085604ad6 --- /dev/null +++ b/stubs/weasyprint/weasyprint/pdf/tags.pyi @@ -0,0 +1 @@ +def add_tags(pdf, document, pdf_version, page_streams) -> None: ... diff --git a/stubs/weasyprint/weasyprint/stacking.pyi b/stubs/weasyprint/weasyprint/stacking.pyi new file mode 100644 index 000000000000..79e0960f6394 --- /dev/null +++ b/stubs/weasyprint/weasyprint/stacking.pyi @@ -0,0 +1,17 @@ +from _typeshed import Incomplete + +class StackingContext: + box: Incomplete + page: Incomplete + block_level_boxes: Incomplete + float_contexts: Incomplete + negative_z_contexts: Incomplete + zero_z_contexts: Incomplete + positive_z_contexts: Incomplete + blocks_and_cells: Incomplete + z_index: Incomplete + def __init__(self, box, child_contexts, blocks, floats, blocks_and_cells, page) -> None: ... + @classmethod + def from_page(cls, page): ... + @classmethod + def from_box(cls, box, page, child_contexts=None): ... diff --git a/stubs/weasyprint/weasyprint/svg/__init__.pyi b/stubs/weasyprint/weasyprint/svg/__init__.pyi new file mode 100644 index 000000000000..97a0721b0ce8 --- /dev/null +++ b/stubs/weasyprint/weasyprint/svg/__init__.pyi @@ -0,0 +1,86 @@ +from _typeshed import Incomplete + +TAGS: Incomplete +NOT_INHERITED_ATTRIBUTES: Incomplete +COLOR_ATTRIBUTES: Incomplete +DEF_TYPES: Incomplete + +class Node: + attrib: Incomplete + vertices: Incomplete + bounding_box: Incomplete + def __init__(self, wrapper, style) -> None: ... + def copy(self): ... + def get(self, key, default=None): ... + @property + def tag(self): ... + @property + def text(self): ... + @property + def tail(self): ... + @property + def display(self): ... + @property + def visible(self): ... + def cascade(self, child) -> None: ... + def __iter__(self): ... + def get_viewbox(self): ... + def get_href(self, base_url): ... + def del_href(self) -> None: ... + @staticmethod + def process_whitespace(string, preserve): ... + def get_child(self, id_): ... + def text_children(self, element, trailing_space, text_root: bool = False): ... + def flatten(self): ... + def pop_rotation(self, original_rotate, rotate) -> None: ... + __class__: Incomplete + def override_iter(self, iterator): ... + def set_svg_size(self, svg, concrete_width, concrete_height) -> None: ... + +class LazyDefs: + def __init__(self, name, svg) -> None: ... + def __getitem__(self, name): ... + def get(self, name): ... + def __contains__(self, name) -> bool: ... + +class SVG: + tree: Incomplete + font_config: Incomplete + url_fetcher: Incomplete + url: Incomplete + filters: Incomplete + gradients: Incomplete + images: Incomplete + markers: Incomplete + masks: Incomplete + patterns: Incomplete + paths: Incomplete + symbols: Incomplete + use_cache: Incomplete + cursor_position: Incomplete + cursor_d_position: Incomplete + text_path_width: int + def __init__(self, tree, url, font_config, url_fetcher=None) -> None: ... + def get_intrinsic_size(self, font_size): ... + def get_viewbox(self): ... + def point(self, x, y, font_size): ... + def length(self, length, font_size): ... + stream: Incomplete + base_url: Incomplete + context: Incomplete + def draw(self, stream, concrete_width, concrete_height, base_url, context) -> None: ... + def draw_node(self, node, font_size, fill_stroke: bool = True) -> None: ... + def draw_markers(self, node, font_size, fill_stroke) -> None: ... + @staticmethod + def get_paint(value): ... + def set_graphical_state(self, node, font_size, text: bool = False) -> None: ... + def fill_stroke(self, node, font_size, text: bool = False) -> None: ... + def transform(self, node, font_size) -> None: ... + def inherit_element(self, element, defs) -> None: ... + def calculate_bounding_box(self, node, font_size, stroke: bool = True): ... + +class Pattern(SVG): + svg: Incomplete + tree: Incomplete + def __init__(self, tree, svg) -> None: ... + def draw_node(self, node, font_size, fill_stroke: bool = True) -> None: ... diff --git a/stubs/weasyprint/weasyprint/svg/bounding_box.pyi b/stubs/weasyprint/weasyprint/svg/bounding_box.pyi new file mode 100644 index 000000000000..8672e182c4c3 --- /dev/null +++ b/stubs/weasyprint/weasyprint/svg/bounding_box.pyi @@ -0,0 +1,18 @@ +from _typeshed import Incomplete + +EMPTY_BOUNDING_BOX: Incomplete + +def bounding_box(svg, node, font_size, stroke): ... +def bounding_box_rect(svg, node, font_size): ... +def bounding_box_circle(svg, node, font_size): ... +def bounding_box_ellipse(svg, node, font_size): ... +def bounding_box_line(svg, node, font_size): ... +def bounding_box_polyline(svg, node, font_size): ... +def bounding_box_path(svg, node, font_size): ... +def bounding_box_text(svg, node, font_size): ... +def bounding_box_g(svg, node, font_size): ... +def bounding_box_use(svg, node, font_size): ... +def extend_bounding_box(bounding_box, points): ... +def is_valid_bounding_box(bounding_box): ... + +BOUNDING_BOX_METHODS: Incomplete diff --git a/stubs/weasyprint/weasyprint/svg/css.pyi b/stubs/weasyprint/weasyprint/svg/css.pyi new file mode 100644 index 000000000000..9a77a533fd9f --- /dev/null +++ b/stubs/weasyprint/weasyprint/svg/css.pyi @@ -0,0 +1,6 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def find_stylesheets_rules(tree, stylesheet_rules, url, font_config, url_fetcher) -> Generator[Incomplete, Incomplete]: ... +def parse_declarations(input): ... +def parse_stylesheets(tree, url, font_config, url_fetcher): ... diff --git a/stubs/weasyprint/weasyprint/svg/defs.pyi b/stubs/weasyprint/weasyprint/svg/defs.pyi new file mode 100644 index 000000000000..927da3debcb4 --- /dev/null +++ b/stubs/weasyprint/weasyprint/svg/defs.pyi @@ -0,0 +1,9 @@ +def get_use_tree(svg, node, font_size): ... +def use(svg, node, font_size) -> None: ... +def draw_gradient_or_pattern(svg, node, name, font_size, opacity, stroke): ... +def draw_gradient(svg, node, gradient, font_size, opacity, stroke): ... +def spread_linear_gradient(spread, positions, colors, x1, y1, x2, y2, bounding_box, matrix): ... +def spread_radial_gradient(spread, positions, colors, fx, fy, fr, cx, cy, r, width, height, matrix): ... +def draw_pattern(svg, node, pattern, font_size, opacity, stroke): ... +def apply_filters(svg, node, filter_node, font_size) -> None: ... +def paint_mask(svg, node, mask, font_size) -> None: ... diff --git a/stubs/weasyprint/weasyprint/svg/images.pyi b/stubs/weasyprint/weasyprint/svg/images.pyi new file mode 100644 index 000000000000..a038f73dcdd0 --- /dev/null +++ b/stubs/weasyprint/weasyprint/svg/images.pyi @@ -0,0 +1,2 @@ +def svg(svg, node, font_size) -> None: ... +def image(svg, node, font_size) -> None: ... diff --git a/stubs/weasyprint/weasyprint/svg/path.pyi b/stubs/weasyprint/weasyprint/svg/path.pyi new file mode 100644 index 000000000000..9147064eb76c --- /dev/null +++ b/stubs/weasyprint/weasyprint/svg/path.pyi @@ -0,0 +1,3 @@ +PATH_LETTERS: str + +def path(svg, node, font_size) -> None: ... diff --git a/stubs/weasyprint/weasyprint/svg/shapes.pyi b/stubs/weasyprint/weasyprint/svg/shapes.pyi new file mode 100644 index 000000000000..ec8a59000fa7 --- /dev/null +++ b/stubs/weasyprint/weasyprint/svg/shapes.pyi @@ -0,0 +1,6 @@ +def circle(svg, node, font_size) -> None: ... +def ellipse(svg, node, font_size) -> None: ... +def rect(svg, node, font_size) -> None: ... +def line(svg, node, font_size) -> None: ... +def polygon(svg, node, font_size) -> None: ... +def polyline(svg, node, font_size) -> None: ... diff --git a/stubs/weasyprint/weasyprint/svg/text.pyi b/stubs/weasyprint/weasyprint/svg/text.pyi new file mode 100644 index 000000000000..5f9b56aa37b2 --- /dev/null +++ b/stubs/weasyprint/weasyprint/svg/text.pyi @@ -0,0 +1,12 @@ +from _typeshed import Incomplete + +class TextBox: + pango_layout: Incomplete + style: Incomplete + def __init__(self, pango_layout, style) -> None: ... + @property + def text(self): ... + +class Style(dict): ... + +def text(svg, node, font_size) -> None: ... diff --git a/stubs/weasyprint/weasyprint/svg/utils.pyi b/stubs/weasyprint/weasyprint/svg/utils.pyi new file mode 100644 index 000000000000..35a15c6ecfa7 --- /dev/null +++ b/stubs/weasyprint/weasyprint/svg/utils.pyi @@ -0,0 +1,11 @@ +class PointError(Exception): ... + +def normalize(string): ... +def size(string, font_size=None, percentage_reference=None): ... +def angle(string): ... +def alpha_value(value): ... +def point(svg, string, font_size): ... +def preserve_ratio(svg, node, font_size, width, height, viewbox=None): ... +def parse_url(url): ... +def color(string): ... +def transform(transform_string, transform_origin, font_size, normalized_diagonal): ... From 9bfef82f0e8b3fc584494cd67c9bef35ba755479 Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 23:12:48 +0200 Subject: [PATCH 38/56] Reformat file --- stubs/weasyprint/weasyprint/layout/__init__.pyi | 2 -- 1 file changed, 2 deletions(-) diff --git a/stubs/weasyprint/weasyprint/layout/__init__.pyi b/stubs/weasyprint/weasyprint/layout/__init__.pyi index 8303fe9bff61..b746f32f6040 100644 --- a/stubs/weasyprint/weasyprint/layout/__init__.pyi +++ b/stubs/weasyprint/weasyprint/layout/__init__.pyi @@ -32,12 +32,10 @@ class LayoutContext: def overflows_page(self, bottom_space, position_y): ... @staticmethod def overflows(bottom, position_y): ... - @property def excluded_shapes(self): ... @excluded_shapes.setter def excluded_shapes(self, excluded_shapes) -> None: ... - def create_block_formatting_context(self, root_box=None, new_list=None) -> None: ... def finish_block_formatting_context(self, root_box=None) -> None: ... def create_flex_formatting_context(self, root_box) -> None: ... From 7604c816b8c53c3c9a3e723325e0bdcac70f3ef4 Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 23:13:02 +0200 Subject: [PATCH 39/56] Fix two more pydyf imports --- stubs/weasyprint/weasyprint/images.pyi | 8 +++++--- stubs/weasyprint/weasyprint/pdf/stream.pyi | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/stubs/weasyprint/weasyprint/images.pyi b/stubs/weasyprint/weasyprint/images.pyi index 05df502acf9f..c787c677c549 100644 --- a/stubs/weasyprint/weasyprint/images.pyi +++ b/stubs/weasyprint/weasyprint/images.pyi @@ -1,6 +1,8 @@ from _typeshed import Incomplete +from typing import Any +from typing_extensions import TypeAlias -import pydyf +_Object: TypeAlias = Any # actually pydyf.Object class ImageLoadingError(ValueError): ... @@ -22,12 +24,12 @@ class RasterImage: def cache_image_data(self, data, filename=None, slot: str = "source"): ... def get_x_object(self, interpolate, dpi_ratio): ... -class LazyImage(pydyf.Object): +class LazyImage(_Object): def __init__(self, cache, key, data) -> None: ... @property def data(self): ... -class LazyLocalImage(pydyf.Object): +class LazyLocalImage(_Object): def __init__(self, filename) -> None: ... @property def data(self): ... diff --git a/stubs/weasyprint/weasyprint/pdf/stream.pyi b/stubs/weasyprint/weasyprint/pdf/stream.pyi index 4ad92e2c2cf3..c7bc97dedd96 100644 --- a/stubs/weasyprint/weasyprint/pdf/stream.pyi +++ b/stubs/weasyprint/weasyprint/pdf/stream.pyi @@ -1,10 +1,12 @@ from _typeshed import Incomplete from collections.abc import Generator from contextlib import contextmanager +from typing import Any +from typing_extensions import TypeAlias -import pydyf +_Stream: TypeAlias = Any # actually pydyf.Stream -class Stream(pydyf.Stream): +class Stream(_Stream): page_rectangle: Incomplete length: Incomplete ink_rect: Incomplete From a2c23d31c5f8390b1fbef0b4503976e3b4b6bc17 Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 23:14:21 +0200 Subject: [PATCH 40/56] Fix pipe character which didn't work here --- stubs/weasyprint/weasyprint/css/units.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/weasyprint/weasyprint/css/units.pyi b/stubs/weasyprint/weasyprint/css/units.pyi index 2e06491028ab..a7c6a3f9ff71 100644 --- a/stubs/weasyprint/weasyprint/css/units.pyi +++ b/stubs/weasyprint/weasyprint/css/units.pyi @@ -6,8 +6,8 @@ RESOLUTION_TO_DPPX: Incomplete ABSOLUTE_UNITS: Incomplete FONT_UNITS: Incomplete VIEWPORT_UNITS: Incomplete -RELATIVE_UNITS = FONT_UNITS | VIEWPORT_UNITS -LENGTH_UNITS = ABSOLUTE_UNITS | RELATIVE_UNITS +RELATIVE_UNITS: Incomplete +LENGTH_UNITS: Incomplete ANGLE_UNITS: Incomplete def to_pixels(value, style, property_name, font_size=None): ... From b356c2bcd238f5f10c20aef6c08f7b5720a2a7cd Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 23:23:25 +0200 Subject: [PATCH 41/56] Try avoiding untyped decorator warnings --- stubs/weasyprint/weasyprint/layout/min_max.pyi | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/stubs/weasyprint/weasyprint/layout/min_max.pyi b/stubs/weasyprint/weasyprint/layout/min_max.pyi index 8bba11f54c73..3fc7011590dd 100644 --- a/stubs/weasyprint/weasyprint/layout/min_max.pyi +++ b/stubs/weasyprint/weasyprint/layout/min_max.pyi @@ -1,2 +1,8 @@ -def handle_min_max_width(function): ... -def handle_min_max_height(function): ... +from collections.abc import Callable +from typing import ParamSpec, TypeVar + +T = TypeVar("T") +P = ParamSpec("P") + +def handle_min_max_width(function: Callable[P, T]) -> Callable[P, T]: ... +def handle_min_max_height(function: Callable[P, T]) -> Callable[P, T]: ... From 59ae0d41ee49b39f51b9c3f7d2e850ce498d7538 Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 23:24:32 +0200 Subject: [PATCH 42/56] Comply with Y001 --- stubs/weasyprint/weasyprint/layout/min_max.pyi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stubs/weasyprint/weasyprint/layout/min_max.pyi b/stubs/weasyprint/weasyprint/layout/min_max.pyi index 3fc7011590dd..3ac24b03118d 100644 --- a/stubs/weasyprint/weasyprint/layout/min_max.pyi +++ b/stubs/weasyprint/weasyprint/layout/min_max.pyi @@ -1,8 +1,8 @@ from collections.abc import Callable from typing import ParamSpec, TypeVar -T = TypeVar("T") -P = ParamSpec("P") +_T = TypeVar("_T") +_P = ParamSpec("_P") -def handle_min_max_width(function: Callable[P, T]) -> Callable[P, T]: ... -def handle_min_max_height(function: Callable[P, T]) -> Callable[P, T]: ... +def handle_min_max_width(function: Callable[_P, _T]) -> Callable[_P, _T]: ... +def handle_min_max_height(function: Callable[_P, _T]) -> Callable[_P, _T]: ... From 1ca9ba990e6a94f61de69a4302efba2bffc95d1f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 Jul 2026 21:28:29 +0000 Subject: [PATCH 43/56] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/weasyprint/weasyprint/images.pyi | 3 +-- stubs/weasyprint/weasyprint/layout/__init__.pyi | 2 ++ stubs/weasyprint/weasyprint/pdf/stream.pyi | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/stubs/weasyprint/weasyprint/images.pyi b/stubs/weasyprint/weasyprint/images.pyi index c787c677c549..ec6e537f70a4 100644 --- a/stubs/weasyprint/weasyprint/images.pyi +++ b/stubs/weasyprint/weasyprint/images.pyi @@ -1,6 +1,5 @@ from _typeshed import Incomplete -from typing import Any -from typing_extensions import TypeAlias +from typing import Any, TypeAlias _Object: TypeAlias = Any # actually pydyf.Object diff --git a/stubs/weasyprint/weasyprint/layout/__init__.pyi b/stubs/weasyprint/weasyprint/layout/__init__.pyi index b746f32f6040..8303fe9bff61 100644 --- a/stubs/weasyprint/weasyprint/layout/__init__.pyi +++ b/stubs/weasyprint/weasyprint/layout/__init__.pyi @@ -32,10 +32,12 @@ class LayoutContext: def overflows_page(self, bottom_space, position_y): ... @staticmethod def overflows(bottom, position_y): ... + @property def excluded_shapes(self): ... @excluded_shapes.setter def excluded_shapes(self, excluded_shapes) -> None: ... + def create_block_formatting_context(self, root_box=None, new_list=None) -> None: ... def finish_block_formatting_context(self, root_box=None) -> None: ... def create_flex_formatting_context(self, root_box) -> None: ... diff --git a/stubs/weasyprint/weasyprint/pdf/stream.pyi b/stubs/weasyprint/weasyprint/pdf/stream.pyi index c7bc97dedd96..15b065226484 100644 --- a/stubs/weasyprint/weasyprint/pdf/stream.pyi +++ b/stubs/weasyprint/weasyprint/pdf/stream.pyi @@ -1,8 +1,7 @@ from _typeshed import Incomplete from collections.abc import Generator from contextlib import contextmanager -from typing import Any -from typing_extensions import TypeAlias +from typing import Any, TypeAlias _Stream: TypeAlias = Any # actually pydyf.Stream From 2b51569650ca58dbc1879ec763264c41c3afedf7 Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 23:41:52 +0200 Subject: [PATCH 44/56] Reformat file --- stubs/weasyprint/weasyprint/layout/__init__.pyi | 2 -- 1 file changed, 2 deletions(-) diff --git a/stubs/weasyprint/weasyprint/layout/__init__.pyi b/stubs/weasyprint/weasyprint/layout/__init__.pyi index 8303fe9bff61..b746f32f6040 100644 --- a/stubs/weasyprint/weasyprint/layout/__init__.pyi +++ b/stubs/weasyprint/weasyprint/layout/__init__.pyi @@ -32,12 +32,10 @@ class LayoutContext: def overflows_page(self, bottom_space, position_y): ... @staticmethod def overflows(bottom, position_y): ... - @property def excluded_shapes(self): ... @excluded_shapes.setter def excluded_shapes(self, excluded_shapes) -> None: ... - def create_block_formatting_context(self, root_box=None, new_list=None) -> None: ... def finish_block_formatting_context(self, root_box=None) -> None: ... def create_flex_formatting_context(self, root_box) -> None: ... From f196a51ac6d67dd72460977213efd4a70005ad6e Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 23:42:03 +0200 Subject: [PATCH 45/56] Cheap out of completely annotating the decorators --- stubs/weasyprint/weasyprint/css/tokens.pyi | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/stubs/weasyprint/weasyprint/css/tokens.pyi b/stubs/weasyprint/weasyprint/css/tokens.pyi index fae461b4ec5e..1197a47c6a18 100644 --- a/stubs/weasyprint/weasyprint/css/tokens.pyi +++ b/stubs/weasyprint/weasyprint/css/tokens.pyi @@ -1,6 +1,10 @@ import abc from _typeshed import Incomplete from abc import ABC, abstractmethod +from collections.abc import Callable, Sequence +from typing import Any, TypeAlias + +_Token: TypeAlias = Any ZERO_PERCENT: Incomplete FIFTY_PERCENT: Incomplete @@ -36,7 +40,7 @@ def split_on_comma(tokens): ... def remove_whitespace(tokens): ... def get_keyword(token): ... def get_custom_ident(token): ... -def get_single_keyword(tokens): ... +def get_single_keyword(tokens: Sequence[_Token]) -> Incomplete | None: ... def get_number(token, negative: bool = True, integer: bool = False): ... def get_string(token): ... def get_percentage(token, negative: bool = True): ... @@ -49,7 +53,7 @@ def get_quote(token): ... def get_target(token, base_url): ... def get_content_list(tokens, base_url): ... def get_content_list_token(token, base_url): ... -def single_keyword(function): ... -def single_token(function): ... -def comma_separated_list(function): ... +def single_keyword(function: Callable[[Incomplete], Incomplete]) -> Callable[[Sequence[_Token]], Incomplete | None]: ... +def single_token(function: Callable[[Incomplete], Incomplete]) -> Callable[[Incomplete], Incomplete]: ... +def comma_separated_list(function: Callable[[Incomplete], Incomplete]) -> Callable[[Incomplete], Incomplete]: ... def tokenize(item, function=None, unit=None): ... From 35d20010aa9f7bedb984f4921dfb78a7c588951a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 Jul 2026 21:44:14 +0000 Subject: [PATCH 46/56] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/weasyprint/weasyprint/layout/__init__.pyi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stubs/weasyprint/weasyprint/layout/__init__.pyi b/stubs/weasyprint/weasyprint/layout/__init__.pyi index b746f32f6040..8303fe9bff61 100644 --- a/stubs/weasyprint/weasyprint/layout/__init__.pyi +++ b/stubs/weasyprint/weasyprint/layout/__init__.pyi @@ -32,10 +32,12 @@ class LayoutContext: def overflows_page(self, bottom_space, position_y): ... @staticmethod def overflows(bottom, position_y): ... + @property def excluded_shapes(self): ... @excluded_shapes.setter def excluded_shapes(self, excluded_shapes) -> None: ... + def create_block_formatting_context(self, root_box=None, new_list=None) -> None: ... def finish_block_formatting_context(self, root_box=None) -> None: ... def create_flex_formatting_context(self, root_box) -> None: ... From 82d2f765391183aee491d5c46209d1908beae83c Mon Sep 17 00:00:00 2001 From: TuringTux Date: Mon, 13 Jul 2026 23:51:02 +0200 Subject: [PATCH 47/56] Add minimally more decorator annotations --- stubs/weasyprint/weasyprint/css/tokens.pyi | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/stubs/weasyprint/weasyprint/css/tokens.pyi b/stubs/weasyprint/weasyprint/css/tokens.pyi index 1197a47c6a18..a984e35f4bc7 100644 --- a/stubs/weasyprint/weasyprint/css/tokens.pyi +++ b/stubs/weasyprint/weasyprint/css/tokens.pyi @@ -2,9 +2,10 @@ import abc from _typeshed import Incomplete from abc import ABC, abstractmethod from collections.abc import Callable, Sequence -from typing import Any, TypeAlias +from typing import Any, TypeAlias, TypeVar _Token: TypeAlias = Any +_T = TypeVar("_T") ZERO_PERCENT: Incomplete FIFTY_PERCENT: Incomplete @@ -54,6 +55,6 @@ def get_target(token, base_url): ... def get_content_list(tokens, base_url): ... def get_content_list_token(token, base_url): ... def single_keyword(function: Callable[[Incomplete], Incomplete]) -> Callable[[Sequence[_Token]], Incomplete | None]: ... -def single_token(function: Callable[[Incomplete], Incomplete]) -> Callable[[Incomplete], Incomplete]: ... -def comma_separated_list(function: Callable[[Incomplete], Incomplete]) -> Callable[[Incomplete], Incomplete]: ... +def single_token(function: Callable[[Incomplete], _T]) -> Callable[[Incomplete], _T | None]: ... +def comma_separated_list(function: Callable[[Incomplete], _T]) -> Callable[[Incomplete], tuple[_T, ...] | None]: ... def tokenize(item, function=None, unit=None): ... From 48dc780e24aff0f917fa79538697a5b84b324dff Mon Sep 17 00:00:00 2001 From: TuringTux Date: Tue, 14 Jul 2026 00:05:41 +0200 Subject: [PATCH 48/56] Annotate single_token better --- stubs/weasyprint/weasyprint/css/tokens.pyi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stubs/weasyprint/weasyprint/css/tokens.pyi b/stubs/weasyprint/weasyprint/css/tokens.pyi index a984e35f4bc7..23959f44b47b 100644 --- a/stubs/weasyprint/weasyprint/css/tokens.pyi +++ b/stubs/weasyprint/weasyprint/css/tokens.pyi @@ -2,10 +2,11 @@ import abc from _typeshed import Incomplete from abc import ABC, abstractmethod from collections.abc import Callable, Sequence -from typing import Any, TypeAlias, TypeVar +from typing import Any, Concatenate, ParamSpec, TypeAlias, TypeVar _Token: TypeAlias = Any _T = TypeVar("_T") +_P = ParamSpec("_P") ZERO_PERCENT: Incomplete FIFTY_PERCENT: Incomplete @@ -55,6 +56,6 @@ def get_target(token, base_url): ... def get_content_list(tokens, base_url): ... def get_content_list_token(token, base_url): ... def single_keyword(function: Callable[[Incomplete], Incomplete]) -> Callable[[Sequence[_Token]], Incomplete | None]: ... -def single_token(function: Callable[[Incomplete], _T]) -> Callable[[Incomplete], _T | None]: ... +def single_token(function: Callable[Concatenate[_Token, _P], _T]) -> Callable[Concatenate[Sequence[_Token], _P], _T | None]: ... def comma_separated_list(function: Callable[[Incomplete], _T]) -> Callable[[Incomplete], tuple[_T, ...] | None]: ... def tokenize(item, function=None, unit=None): ... From b4b670de35c1c94fb21840cc54b34b86d5a0836c Mon Sep 17 00:00:00 2001 From: TuringTux Date: Tue, 14 Jul 2026 00:07:28 +0200 Subject: [PATCH 49/56] Annotate comma_separated_list better --- stubs/weasyprint/weasyprint/css/tokens.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/weasyprint/weasyprint/css/tokens.pyi b/stubs/weasyprint/weasyprint/css/tokens.pyi index 23959f44b47b..71d43276ff81 100644 --- a/stubs/weasyprint/weasyprint/css/tokens.pyi +++ b/stubs/weasyprint/weasyprint/css/tokens.pyi @@ -57,5 +57,5 @@ def get_content_list(tokens, base_url): ... def get_content_list_token(token, base_url): ... def single_keyword(function: Callable[[Incomplete], Incomplete]) -> Callable[[Sequence[_Token]], Incomplete | None]: ... def single_token(function: Callable[Concatenate[_Token, _P], _T]) -> Callable[Concatenate[Sequence[_Token], _P], _T | None]: ... -def comma_separated_list(function: Callable[[Incomplete], _T]) -> Callable[[Incomplete], tuple[_T, ...] | None]: ... +def comma_separated_list(function: Callable[Concatenate[Sequence[_Token], _P], _T]) -> Callable[Concatenate[Sequence[_Token], _P], tuple[_T, ...] | None]: ... def tokenize(item, function=None, unit=None): ... From 7fa626e680125650972676b09989b9117247b35f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 Jul 2026 22:09:45 +0000 Subject: [PATCH 50/56] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/weasyprint/weasyprint/css/tokens.pyi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stubs/weasyprint/weasyprint/css/tokens.pyi b/stubs/weasyprint/weasyprint/css/tokens.pyi index 71d43276ff81..0b53062a4b19 100644 --- a/stubs/weasyprint/weasyprint/css/tokens.pyi +++ b/stubs/weasyprint/weasyprint/css/tokens.pyi @@ -57,5 +57,7 @@ def get_content_list(tokens, base_url): ... def get_content_list_token(token, base_url): ... def single_keyword(function: Callable[[Incomplete], Incomplete]) -> Callable[[Sequence[_Token]], Incomplete | None]: ... def single_token(function: Callable[Concatenate[_Token, _P], _T]) -> Callable[Concatenate[Sequence[_Token], _P], _T | None]: ... -def comma_separated_list(function: Callable[Concatenate[Sequence[_Token], _P], _T]) -> Callable[Concatenate[Sequence[_Token], _P], tuple[_T, ...] | None]: ... +def comma_separated_list( + function: Callable[Concatenate[Sequence[_Token], _P], _T], +) -> Callable[Concatenate[Sequence[_Token], _P], tuple[_T, ...] | None]: ... def tokenize(item, function=None, unit=None): ... From ef51fd6427620d853630925efb61d950007e3a44 Mon Sep 17 00:00:00 2001 From: TuringTux Date: Tue, 14 Jul 2026 00:14:33 +0200 Subject: [PATCH 51/56] Annotate several collections --- stubs/weasyprint/weasyprint/layout/__init__.pyi | 9 +++++---- stubs/weasyprint/weasyprint/layout/flex.pyi | 4 +++- stubs/weasyprint/weasyprint/matrix.pyi | 2 +- stubs/weasyprint/weasyprint/svg/text.pyi | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/stubs/weasyprint/weasyprint/layout/__init__.pyi b/stubs/weasyprint/weasyprint/layout/__init__.pyi index 8303fe9bff61..d04ab2626c0c 100644 --- a/stubs/weasyprint/weasyprint/layout/__init__.pyi +++ b/stubs/weasyprint/weasyprint/layout/__init__.pyi @@ -1,12 +1,15 @@ from _typeshed import Incomplete from collections.abc import Generator +from typing import TypeVar + +_T = TypeVar("_T") def initialize_page_maker(context, root_box) -> None: ... def layout_fixed_boxes(context, pages, containing_page) -> Generator[Incomplete]: ... def layout_document(html, root_box, context, max_loops: int = 8) -> Generator[Incomplete]: ... -class FakeList(list): - def append(self, item) -> None: ... +class FakeList(list[_T]): + def append(self, item: _T) -> None: ... class LayoutContext: style_for: Incomplete @@ -32,12 +35,10 @@ class LayoutContext: def overflows_page(self, bottom_space, position_y): ... @staticmethod def overflows(bottom, position_y): ... - @property def excluded_shapes(self): ... @excluded_shapes.setter def excluded_shapes(self, excluded_shapes) -> None: ... - def create_block_formatting_context(self, root_box=None, new_list=None) -> None: ... def finish_block_formatting_context(self, root_box=None) -> None: ... def create_flex_formatting_context(self, root_box) -> None: ... diff --git a/stubs/weasyprint/weasyprint/layout/flex.pyi b/stubs/weasyprint/weasyprint/layout/flex.pyi index bd73d04d2091..9e04dc8f4edc 100644 --- a/stubs/weasyprint/weasyprint/layout/flex.pyi +++ b/stubs/weasyprint/weasyprint/layout/flex.pyi @@ -1,4 +1,6 @@ -class FlexLine(list): ... +from _typeshed import Incomplete + +class FlexLine(list[Incomplete]): ... def flex_layout( context, box, bottom_space, skip_stack, containing_block, page_is_empty, absolute_boxes, fixed_boxes, discard diff --git a/stubs/weasyprint/weasyprint/matrix.pyi b/stubs/weasyprint/weasyprint/matrix.pyi index 603ceb1a3d6b..15aaba1caab4 100644 --- a/stubs/weasyprint/weasyprint/matrix.pyi +++ b/stubs/weasyprint/weasyprint/matrix.pyi @@ -1,4 +1,4 @@ -class Matrix(list): +class Matrix(list[list[int | float]]): def __init__(self, a: int = 1, b: int = 0, c: int = 0, d: int = 1, e: int = 0, f: int = 0, matrix=None) -> None: ... def __matmul__(self, other): ... @property diff --git a/stubs/weasyprint/weasyprint/svg/text.pyi b/stubs/weasyprint/weasyprint/svg/text.pyi index 5f9b56aa37b2..40763cd1771d 100644 --- a/stubs/weasyprint/weasyprint/svg/text.pyi +++ b/stubs/weasyprint/weasyprint/svg/text.pyi @@ -7,6 +7,6 @@ class TextBox: @property def text(self): ... -class Style(dict): ... +class Style(dict[str, int | str]): ... def text(svg, node, font_size) -> None: ... From 90041c0acb71ba87f1e8224fcffd4e02f3b8e0ad Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 Jul 2026 22:16:50 +0000 Subject: [PATCH 52/56] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/weasyprint/weasyprint/layout/__init__.pyi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stubs/weasyprint/weasyprint/layout/__init__.pyi b/stubs/weasyprint/weasyprint/layout/__init__.pyi index d04ab2626c0c..6282b983fa4e 100644 --- a/stubs/weasyprint/weasyprint/layout/__init__.pyi +++ b/stubs/weasyprint/weasyprint/layout/__init__.pyi @@ -35,10 +35,12 @@ class LayoutContext: def overflows_page(self, bottom_space, position_y): ... @staticmethod def overflows(bottom, position_y): ... + @property def excluded_shapes(self): ... @excluded_shapes.setter def excluded_shapes(self, excluded_shapes) -> None: ... + def create_block_formatting_context(self, root_box=None, new_list=None) -> None: ... def finish_block_formatting_context(self, root_box=None) -> None: ... def create_flex_formatting_context(self, root_box) -> None: ... From fb7c9af5bd7de72406a07089eb58d417bc0a9150 Mon Sep 17 00:00:00 2001 From: TuringTux Date: Tue, 14 Jul 2026 09:31:03 +0200 Subject: [PATCH 53/56] Try cheating my way out of annotating --- stubs/weasyprint/weasyprint/layout/page.pyi | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/stubs/weasyprint/weasyprint/layout/page.pyi b/stubs/weasyprint/weasyprint/layout/page.pyi index 58f1e258b8a2..949db71566ab 100644 --- a/stubs/weasyprint/weasyprint/layout/page.pyi +++ b/stubs/weasyprint/weasyprint/layout/page.pyi @@ -14,11 +14,8 @@ class PageType(NamedTuple): class OrientedBox: @property def sugar(self): ... - @property - def outer(self): ... + outer: Incomplete inner: Incomplete - @outer.setter - def outer(self, new_outer_width) -> None: ... @property def outer_min_content_size(self): ... @property From b0e0995cfb07257cbffe309393e59986c7fb7b7c Mon Sep 17 00:00:00 2001 From: TuringTux Date: Tue, 14 Jul 2026 09:42:09 +0200 Subject: [PATCH 54/56] Adjust exports --- stubs/weasyprint/weasyprint/__init__.pyi | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/stubs/weasyprint/weasyprint/__init__.pyi b/stubs/weasyprint/weasyprint/__init__.pyi index a672d30b0d93..bd9e19626005 100644 --- a/stubs/weasyprint/weasyprint/__init__.pyi +++ b/stubs/weasyprint/weasyprint/__init__.pyi @@ -26,16 +26,13 @@ __all__ = [ "Page", "__version__", "default_url_fetcher", - "Options", - "PageRule", - "Selector", ] VERSION: str __version__: str -DEFAULT_OPTIONS: Options +DEFAULT_OPTIONS: _Options -class Options(TypedDict): +class _Options(TypedDict): stylesheets: Incomplete attachments: Incomplete attachment_relationships: Incomplete @@ -56,8 +53,8 @@ class Options(TypedDict): hinting: Incomplete cache: Incomplete -Selector: TypeAlias = tuple[Incomplete, str | None, Incomplete] -PageRule: TypeAlias = tuple[Incomplete, list[Selector], Incomplete] +_Selector: TypeAlias = tuple[Incomplete, str | None, Incomplete] +_PageRule: TypeAlias = tuple[Incomplete, list[_Selector], Incomplete] class HTML: base_url: str | Path | None # undocumented @@ -82,7 +79,7 @@ class HTML: font_config: FontConfiguration | None = None, counter_style: CounterStyle | None = None, color_profiles: dict[str, ColorProfile] | None = None, - **options: Unpack[Options], + **options: Unpack[_Options], ) -> Document: ... def write_pdf( self, @@ -92,13 +89,13 @@ class HTML: font_config: FontConfiguration | None = None, counter_style: CounterStyle | None = None, color_profiles: dict[str, ColorProfile] | None = None, - **options: Unpack[Options], + **options: Unpack[_Options], ) -> bytes | None: ... class CSS: base_url: str | Path | None # undocumented matcher: _Matcher # undocumented - page_rules: list[PageRule] # undocumented + page_rules: list[_PageRule] # undocumented layers: list[str] # undocumented def __init__( self, @@ -116,7 +113,7 @@ class CSS: counter_style: CounterStyle | None = None, color_profiles: dict[str, ColorProfile] | None = None, matcher: _Matcher | None = None, - page_rules: list[PageRule] | None = None, + page_rules: list[_PageRule] | None = None, layers: list[str] | None = None, layer: str | None = None, ) -> None: ... From 69932c94412a08dc6596ffed38d352c8f077aeda Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 14 Jul 2026 07:44:14 +0000 Subject: [PATCH 55/56] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/weasyprint/weasyprint/__init__.pyi | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/stubs/weasyprint/weasyprint/__init__.pyi b/stubs/weasyprint/weasyprint/__init__.pyi index bd9e19626005..169ba242a563 100644 --- a/stubs/weasyprint/weasyprint/__init__.pyi +++ b/stubs/weasyprint/weasyprint/__init__.pyi @@ -16,17 +16,7 @@ _ElementWrapper: TypeAlias = Any # actually csselect2.ElementWrapper _Matcher: TypeAlias = Any # actually csselect2.Matcher _PDF: TypeAlias = Any # actually pydyf.PDF -__all__ = [ - "CSS", - "DEFAULT_OPTIONS", - "HTML", - "VERSION", - "Attachment", - "Document", - "Page", - "__version__", - "default_url_fetcher", -] +__all__ = ["CSS", "DEFAULT_OPTIONS", "HTML", "VERSION", "Attachment", "Document", "Page", "__version__", "default_url_fetcher"] VERSION: str __version__: str From 0488652621637707ea7e0748ca2ebe42c78e7492 Mon Sep 17 00:00:00 2001 From: TuringTux Date: Tue, 14 Jul 2026 09:46:58 +0200 Subject: [PATCH 56/56] Mark _Options as type check only --- stubs/weasyprint/weasyprint/__init__.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stubs/weasyprint/weasyprint/__init__.pyi b/stubs/weasyprint/weasyprint/__init__.pyi index 169ba242a563..1eb4032d412a 100644 --- a/stubs/weasyprint/weasyprint/__init__.pyi +++ b/stubs/weasyprint/weasyprint/__init__.pyi @@ -2,7 +2,7 @@ from _typeshed import Incomplete from collections.abc import Callable from datetime import datetime from pathlib import Path -from typing import Any, BinaryIO, TextIO, TypeAlias, TypedDict +from typing import Any, BinaryIO, TextIO, TypeAlias, TypedDict, type_check_only from typing_extensions import Unpack from xml.etree.ElementTree import Element @@ -22,6 +22,7 @@ VERSION: str __version__: str DEFAULT_OPTIONS: _Options +@type_check_only class _Options(TypedDict): stylesheets: Incomplete attachments: Incomplete