Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyrightconfig.stricter.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
"stubs/tensorflow",
"stubs/tqdm",
"stubs/vobject",
"stubs/weasyprint",
"stubs/workalendar",
"stubs/xmldiff",
],
Expand Down
2 changes: 2 additions & 0 deletions stubs/weasyprint/METADATA.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version = "68.0.*"
upstream_repository = "https://github.com/Kozea/WeasyPrint"
84 changes: 84 additions & 0 deletions stubs/weasyprint/weasyprint/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
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

__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: str | Path | None = None,
url: str | None = None,
file_obj=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) -> 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
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: ...
3 changes: 3 additions & 0 deletions stubs/weasyprint/weasyprint/anchors.pyi
Original file line number Diff line number Diff line change
@@ -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): ...
106 changes: 106 additions & 0 deletions stubs/weasyprint/weasyprint/css/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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):

Check failure on line 33 in stubs/weasyprint/weasyprint/css/__init__.pyi

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

Expected type arguments for generic class "dict" (reportMissingTypeArgument)
parent_style: Incomplete
specified: Incomplete
cache: Incomplete
font_config: Incomplete
def __init__(self, font_config) -> None: ...
def __missing__(self, key): ...

class AnonymousStyle(dict):

Check failure on line 41 in stubs/weasyprint/weasyprint/css/__init__.pyi

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

Expected type arguments for generic class "dict" (reportMissingTypeArgument)
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):

Check failure on line 51 in stubs/weasyprint/weasyprint/css/__init__.pyi

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

Expected type arguments for generic class "dict" (reportMissingTypeArgument)
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,
): ...
47 changes: 47 additions & 0 deletions stubs/weasyprint/weasyprint/css/computed_values.pyi
Original file line number Diff line number Diff line change
@@ -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): ...
8 changes: 8 additions & 0 deletions stubs/weasyprint/weasyprint/css/counters.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def symbol(string_or_url): ...
def parse_counter_style_name(tokens, counter_style): ...

class CounterStyle(dict):

Check failure on line 4 in stubs/weasyprint/weasyprint/css/counters.pyi

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

Expected type arguments for generic class "dict" (reportMissingTypeArgument)
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): ...
15 changes: 15 additions & 0 deletions stubs/weasyprint/weasyprint/css/functions.pyi
Original file line number Diff line number Diff line change
@@ -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): ...
2 changes: 2 additions & 0 deletions stubs/weasyprint/weasyprint/css/media_queries.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def evaluate_media_query(query_list, device_media_type): ...
def parse_media_query(tokens): ...
13 changes: 13 additions & 0 deletions stubs/weasyprint/weasyprint/css/properties.pyi
Original file line number Diff line number Diff line change
@@ -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
35 changes: 35 additions & 0 deletions stubs/weasyprint/weasyprint/css/targets.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
55 changes: 55 additions & 0 deletions stubs/weasyprint/weasyprint/css/tokens.pyi
Original file line number Diff line number Diff line change
@@ -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): ...
Loading
Loading