Skip to content

Commit d03c6f2

Browse files
committed
[tinycss2] Add stubs for tinycss2
1 parent 4f08613 commit d03c6f2

11 files changed

Lines changed: 270 additions & 0 deletions

File tree

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: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from .bytes import parse_stylesheet_bytes as parse_stylesheet_bytes
2+
from .parser import (
3+
parse_blocks_contents as parse_blocks_contents,
4+
parse_declaration_list as parse_declaration_list,
5+
parse_one_component_value as parse_one_component_value,
6+
parse_one_declaration as parse_one_declaration,
7+
parse_one_rule as parse_one_rule,
8+
parse_rule_list as parse_rule_list,
9+
parse_stylesheet as parse_stylesheet,
10+
)
11+
from .serializer import serialize as serialize, serialize_identifier as serialize_identifier
12+
from .tokenizer import parse_component_value_list as parse_component_value_list
13+
14+
__version__: str = ...

stubs/tinycss2/tinycss2/ast.pyi

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

stubs/tinycss2/tinycss2/color5.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 Literal
3+
4+
from . import color4
5+
from .ast import Node
6+
7+
class Color(color4.Color):
8+
COLOR_SPACES: set[str]
9+
10+
def parse_color(
11+
input: str | Iterable[Node], color_schemes: Literal["normal"] | Iterable[str] = ...
12+
) -> color4.Color | Color | Literal["currentcolor"] | None: ...

stubs/tinycss2/tinycss2/nth.pyi

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

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 = ...) -> Node: ...
9+
def parse_one_declaration(input: str | Iterable[Node], skip_comments: bool = ...) -> Declaration | ParseError: ...
10+
def parse_blocks_contents(
11+
input: str | Iterable[Node], skip_comments: bool = ..., skip_whitespace: bool = ...
12+
) -> list[Declaration | AtRule | QualifiedRule | Comment | WhitespaceToken | ParseError]: ...
13+
def parse_declaration_list(
14+
input: str | Iterable[Node], skip_comments: bool = ..., skip_whitespace: bool = ...
15+
) -> list[Declaration | AtRule | Comment | WhitespaceToken | ParseError]: ...
16+
def parse_one_rule(input: str | Iterable[Node], skip_comments: bool = ...) -> QualifiedRule | AtRule | ParseError: ...
17+
def parse_rule_list(input: str | Iterable[Node], skip_comments: bool = ..., skip_whitespace: bool = ...) -> list[Rule]: ...
18+
def parse_stylesheet(input: str | Iterable[Node], skip_comments: bool = ..., skip_whitespace: bool = ...) -> list[Rule]: ...
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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: ...

0 commit comments

Comments
 (0)