Skip to content

Commit 6180fa0

Browse files
authored
[tinycss2] Add stubs (#15623)
1 parent 46b01bf commit 6180fa0

File tree

11 files changed

+285
-0
lines changed

11 files changed

+285
-0
lines changed

stubs/tinycss2/METADATA.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version = "1.5.1"
2+
upstream-repository = "https://github.com/Kozea/tinycss2"
3+
dependencies = ["types-webencodings"]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from typing import Final
2+
3+
from .bytes import parse_stylesheet_bytes as parse_stylesheet_bytes
4+
from .parser import (
5+
parse_blocks_contents as parse_blocks_contents,
6+
parse_declaration_list as parse_declaration_list,
7+
parse_one_component_value as parse_one_component_value,
8+
parse_one_declaration as parse_one_declaration,
9+
parse_one_rule as parse_one_rule,
10+
parse_rule_list as parse_rule_list,
11+
parse_stylesheet as parse_stylesheet,
12+
)
13+
from .serializer import serialize as serialize, serialize_identifier as serialize_identifier
14+
from .tokenizer import parse_component_value_list as parse_component_value_list
15+
16+
__version__: Final[str]
17+
VERSION: Final[str]

stubs/tinycss2/tinycss2/ast.pyi

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
from typing import Literal
2+
3+
class Node:
4+
source_line: int
5+
source_column: int
6+
type: str
7+
8+
def __init__(self, source_line: int, source_column: int) -> None: ...
9+
def serialize(self) -> str: ...
10+
11+
class ParseError(Node):
12+
type: Literal["error"]
13+
kind: str
14+
message: str
15+
repr_format: str
16+
def __init__(self, line: int, column: int, kind: str, message: str) -> None: ...
17+
18+
class Comment(Node):
19+
type: Literal["comment"]
20+
value: str
21+
repr_format: str
22+
def __init__(self, line: int, column: int, value: str) -> None: ...
23+
24+
class WhitespaceToken(Node):
25+
type: Literal["whitespace"]
26+
value: str
27+
repr_format: str
28+
def __init__(self, line: int, column: int, value: str) -> None: ...
29+
30+
class LiteralToken(Node):
31+
type: Literal["literal"]
32+
value: str
33+
repr_format: str
34+
def __init__(self, line: int, column: int, value: str) -> None: ...
35+
def __eq__(self, other: object) -> bool: ...
36+
def __ne__(self, other: object) -> bool: ...
37+
38+
class IdentToken(Node):
39+
type: Literal["ident"]
40+
value: str
41+
lower_value: str
42+
repr_format: str
43+
def __init__(self, line: int, column: int, value: str) -> None: ...
44+
45+
class AtKeywordToken(Node):
46+
type: Literal["at-keyword"]
47+
value: str
48+
lower_value: str
49+
repr_format: str
50+
def __init__(self, line: int, column: int, value: str) -> None: ...
51+
52+
class HashToken(Node):
53+
type: Literal["hash"]
54+
value: str
55+
is_identifier: bool
56+
repr_format: str
57+
def __init__(self, line: int, column: int, value: str, is_identifier: bool) -> None: ...
58+
59+
class StringToken(Node):
60+
type: Literal["string"]
61+
value: str
62+
representation: str
63+
repr_format: str
64+
def __init__(self, line: int, column: int, value: str, representation: str) -> None: ...
65+
66+
class URLToken(Node):
67+
type: Literal["url"]
68+
value: str
69+
representation: str
70+
repr_format: str
71+
def __init__(self, line: int, column: int, value: str, representation: str) -> None: ...
72+
73+
class UnicodeRangeToken(Node):
74+
type: Literal["unicode-range"]
75+
start: int
76+
end: int
77+
repr_format: str
78+
def __init__(self, line: int, column: int, start: int, end: int) -> None: ...
79+
80+
class NumberToken(Node):
81+
type: Literal["number"]
82+
value: float
83+
int_value: int | None
84+
is_integer: bool
85+
representation: str
86+
repr_format: str
87+
def __init__(self, line: int, column: int, value: float, int_value: int | None, representation: str) -> None: ...
88+
89+
class PercentageToken(Node):
90+
type: Literal["percentage"]
91+
value: float
92+
int_value: int | None
93+
is_integer: bool
94+
representation: str
95+
repr_format: str
96+
def __init__(self, line: int, column: int, value: float, int_value: int | None, representation: str) -> None: ...
97+
98+
class DimensionToken(Node):
99+
type: Literal["dimension"]
100+
value: float
101+
int_value: int | None
102+
is_integer: bool
103+
representation: str
104+
unit: str
105+
lower_unit: str
106+
repr_format: str
107+
def __init__(self, line: int, column: int, value: float, int_value: int | None, representation: str, unit: str) -> None: ...
108+
109+
class ParenthesesBlock(Node):
110+
type: Literal["() block"]
111+
content: list[Node]
112+
repr_format: str
113+
def __init__(self, line: int, column: int, content: list[Node]) -> None: ...
114+
115+
class SquareBracketsBlock(Node):
116+
type: Literal["[] block"]
117+
content: list[Node]
118+
repr_format: str
119+
def __init__(self, line: int, column: int, content: list[Node]) -> None: ...
120+
121+
class CurlyBracketsBlock(Node):
122+
type: Literal["{} block"]
123+
content: list[Node]
124+
repr_format: str
125+
def __init__(self, line: int, column: int, content: list[Node]) -> None: ...
126+
127+
class FunctionBlock(Node):
128+
type: Literal["function"]
129+
name: str
130+
lower_name: str
131+
arguments: list[Node]
132+
repr_format: str
133+
def __init__(self, line: int, column: int, name: str, arguments: list[Node]) -> None: ...
134+
135+
class Declaration(Node):
136+
type: Literal["declaration"]
137+
name: str
138+
lower_name: str
139+
value: list[Node]
140+
important: bool
141+
repr_format: str
142+
def __init__(self, line: int, column: int, name: str, lower_name: str, value: list[Node], important: bool) -> None: ...
143+
144+
class QualifiedRule(Node):
145+
type: Literal["qualified-rule"]
146+
prelude: list[Node]
147+
content: list[Node]
148+
repr_format: str
149+
def __init__(self, line: int, column: int, prelude: list[Node], content: list[Node]) -> None: ...
150+
151+
class AtRule(Node):
152+
type: Literal["at-rule"]
153+
at_keyword: str
154+
lower_at_keyword: str
155+
prelude: list[Node]
156+
content: list[Node] | None
157+
repr_format: str
158+
def __init__(
159+
self, line: int, column: int, at_keyword: str, lower_at_keyword: str, prelude: list[Node], content: list[Node] | None
160+
) -> None: ...

stubs/tinycss2/tinycss2/bytes.pyi

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from webencodings import Encoding
2+
3+
from .ast import Node
4+
5+
def decode_stylesheet_bytes(
6+
css_bytes: bytes, protocol_encoding: str | None = None, environment_encoding: Encoding | None = None
7+
) -> tuple[str, Encoding]: ...
8+
def parse_stylesheet_bytes(
9+
css_bytes: bytes,
10+
protocol_encoding: str | None = None,
11+
environment_encoding: Encoding | None = None,
12+
skip_comments: bool = False,
13+
skip_whitespace: bool = False,
14+
) -> tuple[list[Node], Encoding]: ...

stubs/tinycss2/tinycss2/color3.pyi

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from collections.abc import Iterable
2+
from typing import NamedTuple
3+
4+
from .ast import Node
5+
6+
class RGBA(NamedTuple):
7+
red: float
8+
green: float
9+
blue: float
10+
alpha: float
11+
12+
def parse_color(input: str | Iterable[Node]) -> str | RGBA | None: ...

stubs/tinycss2/tinycss2/color4.pyi

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from collections.abc import Iterable, Iterator
2+
from typing import Literal
3+
4+
from .ast import Node
5+
6+
class Color:
7+
COLOR_SPACES: set[str] | None
8+
def __init__(self, space: str, coordinates: tuple[float | None, ...], alpha: float) -> None: ...
9+
def __iter__(self) -> Iterator[float | None]: ...
10+
def __getitem__(self, key: int) -> float: ...
11+
def __hash__(self) -> int: ...
12+
def __eq__(self, other: object) -> bool: ...
13+
def to(self, space: str) -> Color: ...
14+
15+
def parse_color(input: str | Iterable[Node]) -> Color | Literal["currentcolor"] | None: ...
16+
17+
COLOR_SPACES: set[str]
18+
D50: tuple[float, float, float]
19+
D65: tuple[float, float, float]

stubs/tinycss2/tinycss2/color5.pyi

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from collections.abc import Iterable
2+
from typing import Literal
3+
4+
from . import color4
5+
from .ast import Node
6+
7+
COLOR_SCHEMES: set[str]
8+
COLOR_SPACES: set[str]
9+
D50: tuple[float, float, float]
10+
D65: tuple[float, float, float]
11+
12+
class Color(color4.Color):
13+
COLOR_SPACES: set[str] | None
14+
15+
def parse_color(
16+
input: str | Iterable[Node], color_schemes: Literal["normal"] | Iterable[str] | None = None
17+
) -> color4.Color | Color | Literal["currentcolor"] | None: ...

stubs/tinycss2/tinycss2/nth.pyi

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from collections.abc import Iterable
2+
from re import Pattern
3+
4+
from .ast import Node
5+
6+
def parse_nth(input: str | Iterable[Node]) -> tuple[int, int] | None: ...
7+
def parse_b(tokens: Iterable[Node], a: int) -> tuple[int, int] | None: ...
8+
def parse_signless_b(tokens: Iterable[Node], a: int, b_sign: int) -> tuple[int, int] | None: ...
9+
def parse_end(tokens: Iterable[Node], a: int, b: int) -> tuple[int, int] | None: ...
10+
11+
N_DASH_DIGITS_RE: Pattern[str]

stubs/tinycss2/tinycss2/parser.pyi

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from collections.abc import Iterable
2+
from typing import TypeAlias
3+
4+
from .ast import AtRule, Comment, Declaration, Node, ParseError, QualifiedRule, WhitespaceToken
5+
6+
_Rule: TypeAlias = QualifiedRule | AtRule | Comment | WhitespaceToken | ParseError
7+
8+
def parse_one_component_value(input: str | Iterable[Node], skip_comments: bool = False) -> Node: ...
9+
def parse_one_declaration(input: str | Iterable[Node], skip_comments: bool = False) -> Declaration | ParseError: ...
10+
def parse_blocks_contents(
11+
input: str | Iterable[Node], skip_comments: bool = False, skip_whitespace: bool = False
12+
) -> list[Declaration | AtRule | QualifiedRule | Comment | WhitespaceToken | ParseError]: ...
13+
def parse_declaration_list(
14+
input: str | Iterable[Node], skip_comments: bool = False, skip_whitespace: bool = False
15+
) -> list[Declaration | AtRule | Comment | WhitespaceToken | ParseError]: ...
16+
def parse_one_rule(input: str | Iterable[Node], skip_comments: bool = False) -> QualifiedRule | AtRule | ParseError: ...
17+
def parse_rule_list(input: str | Iterable[Node], skip_comments: bool = False, skip_whitespace: bool = False) -> list[_Rule]: ...
18+
def parse_stylesheet(input: str | Iterable[Node], skip_comments: bool = False, skip_whitespace: bool = False) -> list[_Rule]: ...
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from collections.abc import Iterable
2+
3+
from .ast import Node
4+
5+
def serialize(nodes: Iterable[Node]) -> str: ...
6+
def serialize_identifier(value: str) -> str: ...
7+
def serialize_name(value: str) -> str: ...
8+
def serialize_string_value(value: str) -> str: ...
9+
def serialize_url(value: str) -> str: ...
10+
11+
BAD_PAIRS: set[tuple[str, str]]

0 commit comments

Comments
 (0)