-
-
Notifications
You must be signed in to change notification settings - Fork 2k
[tinycss2] Add stubs for tinycss2 #15623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
d03c6f2
d5bf66c
dec38e3
45bb75c
e360840
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| version = "1.5.1" | ||
| upstream_repository = "https://github.com/Kozea/tinycss2" | ||
| dependencies = ["types-webencodings"] | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,15 @@ | ||||||||||
| from .bytes import parse_stylesheet_bytes as parse_stylesheet_bytes | ||||||||||
| from .parser import ( | ||||||||||
| parse_blocks_contents as parse_blocks_contents, | ||||||||||
| parse_declaration_list as parse_declaration_list, | ||||||||||
| parse_one_component_value as parse_one_component_value, | ||||||||||
| parse_one_declaration as parse_one_declaration, | ||||||||||
| parse_one_rule as parse_one_rule, | ||||||||||
| parse_rule_list as parse_rule_list, | ||||||||||
| parse_stylesheet as parse_stylesheet, | ||||||||||
| ) | ||||||||||
| from .serializer import serialize as serialize, serialize_identifier as serialize_identifier | ||||||||||
| from .tokenizer import parse_component_value_list as parse_component_value_list | ||||||||||
|
|
||||||||||
| __version__: str = ... | ||||||||||
| VERSION: str = ... | ||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
( |
||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,160 @@ | ||||||
| from typing import Literal | ||||||
|
|
||||||
| class Node: | ||||||
| source_line: int | ||||||
| source_column: int | ||||||
| type: str | ||||||
|
|
||||||
| def __init__(self, source_line: int, source_column: int) -> None: ... | ||||||
| def serialize(self) -> str: ... | ||||||
|
|
||||||
| class ParseError(Node): | ||||||
| type: Literal["error"] | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It probably makes sense to use
Suggested change
|
||||||
| kind: str | ||||||
| message: str | ||||||
| repr_format: str | ||||||
| def __init__(self, line: int, column: int, kind: str, message: str) -> None: ... | ||||||
|
|
||||||
| class Comment(Node): | ||||||
| type: Literal["comment"] | ||||||
| value: str | ||||||
| repr_format: str | ||||||
| def __init__(self, line: int, column: int, value: str) -> None: ... | ||||||
|
|
||||||
| class WhitespaceToken(Node): | ||||||
| type: Literal["whitespace"] | ||||||
| value: str | ||||||
| repr_format: str | ||||||
| def __init__(self, line: int, column: int, value: str) -> None: ... | ||||||
|
|
||||||
| class LiteralToken(Node): | ||||||
| type: Literal["literal"] | ||||||
| value: str | ||||||
| repr_format: str | ||||||
| def __init__(self, line: int, column: int, value: str) -> None: ... | ||||||
| def __eq__(self, other: object) -> bool: ... | ||||||
| def __ne__(self, other: object) -> bool: ... | ||||||
|
|
||||||
| class IdentToken(Node): | ||||||
| type: Literal["ident"] | ||||||
| value: str | ||||||
| lower_value: str | ||||||
| repr_format: str | ||||||
| def __init__(self, line: int, column: int, value: str) -> None: ... | ||||||
|
|
||||||
| class AtKeywordToken(Node): | ||||||
| type: Literal["at-keyword"] | ||||||
| value: str | ||||||
| lower_value: str | ||||||
| repr_format: str | ||||||
| def __init__(self, line: int, column: int, value: str) -> None: ... | ||||||
|
|
||||||
| class HashToken(Node): | ||||||
| type: Literal["hash"] | ||||||
| value: str | ||||||
| is_identifier: bool | ||||||
| repr_format: str | ||||||
| def __init__(self, line: int, column: int, value: str, is_identifier: bool) -> None: ... | ||||||
|
|
||||||
| class StringToken(Node): | ||||||
| type: Literal["string"] | ||||||
| value: str | ||||||
| representation: str | ||||||
| repr_format: str | ||||||
| def __init__(self, line: int, column: int, value: str, representation: str) -> None: ... | ||||||
|
|
||||||
| class URLToken(Node): | ||||||
| type: Literal["url"] | ||||||
| value: str | ||||||
| representation: str | ||||||
| repr_format: str | ||||||
| def __init__(self, line: int, column: int, value: str, representation: str) -> None: ... | ||||||
|
|
||||||
| class UnicodeRangeToken(Node): | ||||||
| type: Literal["unicode-range"] | ||||||
| start: int | ||||||
| end: int | ||||||
| repr_format: str | ||||||
| def __init__(self, line: int, column: int, start: int, end: int) -> None: ... | ||||||
|
|
||||||
| class NumberToken(Node): | ||||||
| type: Literal["number"] | ||||||
| value: float | ||||||
| int_value: int | None | ||||||
| is_integer: bool | ||||||
| representation: str | ||||||
| repr_format: str | ||||||
| def __init__(self, line: int, column: int, value: float, int_value: int | None, representation: str) -> None: ... | ||||||
|
|
||||||
| class PercentageToken(Node): | ||||||
| type: Literal["percentage"] | ||||||
| value: float | ||||||
| int_value: int | None | ||||||
| is_integer: bool | ||||||
| representation: str | ||||||
| repr_format: str | ||||||
| def __init__(self, line: int, column: int, value: float, int_value: int | None, representation: str) -> None: ... | ||||||
|
|
||||||
| class DimensionToken(Node): | ||||||
| type: Literal["dimension"] | ||||||
| value: float | ||||||
| int_value: int | None | ||||||
| is_integer: bool | ||||||
| representation: str | ||||||
| unit: str | ||||||
| lower_unit: str | ||||||
| repr_format: str | ||||||
| def __init__(self, line: int, column: int, value: float, int_value: int | None, representation: str, unit: str) -> None: ... | ||||||
|
|
||||||
| class ParenthesesBlock(Node): | ||||||
| type: Literal["() block"] | ||||||
| content: list[Node] | ||||||
| repr_format: str | ||||||
| def __init__(self, line: int, column: int, content: list[Node]) -> None: ... | ||||||
|
|
||||||
| class SquareBracketsBlock(Node): | ||||||
| type: Literal["[] block"] | ||||||
| content: list[Node] | ||||||
| repr_format: str | ||||||
| def __init__(self, line: int, column: int, content: list[Node]) -> None: ... | ||||||
|
|
||||||
| class CurlyBracketsBlock(Node): | ||||||
| type: Literal["{} block"] | ||||||
| content: list[Node] | ||||||
| repr_format: str | ||||||
| def __init__(self, line: int, column: int, content: list[Node]) -> None: ... | ||||||
|
|
||||||
| class FunctionBlock(Node): | ||||||
| type: Literal["function"] | ||||||
| name: str | ||||||
| lower_name: str | ||||||
| arguments: list[Node] | ||||||
| repr_format: str | ||||||
| def __init__(self, line: int, column: int, name: str, arguments: list[Node]) -> None: ... | ||||||
|
|
||||||
| class Declaration(Node): | ||||||
| type: Literal["declaration"] | ||||||
| name: str | ||||||
| lower_name: str | ||||||
| value: list[Node] | ||||||
| important: bool | ||||||
| repr_format: str | ||||||
| def __init__(self, line: int, column: int, name: str, lower_name: str, value: list[Node], important: bool) -> None: ... | ||||||
|
|
||||||
| class QualifiedRule(Node): | ||||||
| type: Literal["qualified-rule"] | ||||||
| prelude: list[Node] | ||||||
| content: list[Node] | ||||||
| repr_format: str | ||||||
| def __init__(self, line: int, column: int, prelude: list[Node], content: list[Node]) -> None: ... | ||||||
|
|
||||||
| class AtRule(Node): | ||||||
| type: Literal["at-rule"] | ||||||
| at_keyword: str | ||||||
| lower_at_keyword: str | ||||||
| prelude: list[Node] | ||||||
| content: list[Node] | None | ||||||
| repr_format: str | ||||||
| def __init__( | ||||||
| self, line: int, column: int, at_keyword: str, lower_at_keyword: str, prelude: list[Node], content: list[Node] | None | ||||||
| ) -> None: ... | ||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,14 @@ | ||||||||||||||||||
| from webencodings import Encoding | ||||||||||||||||||
|
|
||||||||||||||||||
| from .ast import Node | ||||||||||||||||||
|
|
||||||||||||||||||
| def decode_stylesheet_bytes( | ||||||||||||||||||
| css_bytes: bytes, protocol_encoding: str | None = ..., environment_encoding: Encoding | None = ... | ||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We now generally add simple defaults to typeshed, instead of
Suggested change
|
||||||||||||||||||
| ) -> tuple[str, Encoding]: ... | ||||||||||||||||||
| def parse_stylesheet_bytes( | ||||||||||||||||||
| css_bytes: bytes, | ||||||||||||||||||
| protocol_encoding: str | None = ..., | ||||||||||||||||||
| environment_encoding: Encoding | None = ..., | ||||||||||||||||||
| skip_comments: bool = ..., | ||||||||||||||||||
| skip_whitespace: bool = ..., | ||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
| ) -> tuple[list[Node], Encoding]: ... | ||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| from collections.abc import Iterable | ||
| from typing import NamedTuple | ||
|
|
||
| from .ast import Node | ||
|
|
||
| class RGBA(NamedTuple): | ||
| red: float | ||
| green: float | ||
| blue: float | ||
| alpha: float | ||
|
|
||
| def parse_color(input: str | Iterable[Node]) -> str | RGBA | None: ... |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| from collections.abc import Iterable, Iterator | ||
| from typing import Literal | ||
|
|
||
| from .ast import Node | ||
|
|
||
| class Color: | ||
| COLOR_SPACES: set[str] | None | ||
| def __init__(self, space: str, coordinates: tuple[float | None, ...], alpha: float) -> None: ... | ||
| def __iter__(self) -> Iterator[float | None]: ... | ||
| def __getitem__(self, key: int) -> float: ... | ||
| def __hash__(self) -> int: ... | ||
| def __eq__(self, other: object) -> bool: ... | ||
| def to(self, space: str) -> Color: ... | ||
|
|
||
| def parse_color(input: str | Iterable[Node]) -> Color | Literal["currentcolor"] | None: ... | ||
|
|
||
| COLOR_SPACES: set[str] | ||
| D50: tuple[float, float, float] | ||
| D65: tuple[float, float, float] |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,17 @@ | ||||||
| from collections.abc import Iterable | ||||||
| from typing import Literal | ||||||
|
|
||||||
| from . import color4 | ||||||
| from .ast import Node | ||||||
|
|
||||||
| COLOR_SCHEMES: set[str] | ||||||
| COLOR_SPACES: set[str] | ||||||
| D50: tuple[float, float, float] | ||||||
| D65: tuple[float, float, float] | ||||||
|
|
||||||
| class Color(color4.Color): | ||||||
| COLOR_SPACES: set[str] | None | ||||||
|
|
||||||
| def parse_color( | ||||||
| input: str | Iterable[Node], color_schemes: Literal["normal"] | Iterable[str] | None = ... | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| ) -> color4.Color | Color | Literal["currentcolor"] | None: ... | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| from collections.abc import Iterable | ||
| from re import Pattern | ||
|
|
||
| from .ast import Node | ||
|
|
||
| def parse_nth(input: str | Iterable[Node]) -> tuple[int, int] | None: ... | ||
| def parse_b(tokens: Iterable[Node], a: int) -> tuple[int, int] | None: ... | ||
| def parse_signless_b(tokens: Iterable[Node], a: int, b_sign: int) -> tuple[int, int] | None: ... | ||
| def parse_end(tokens: Iterable[Node], a: int, b: int) -> tuple[int, int] | None: ... | ||
|
|
||
| N_DASH_DIGITS_RE: Pattern[str] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| from collections.abc import Iterable | ||
| from typing import TypeAlias | ||
|
|
||
| from .ast import AtRule, Comment, Declaration, Node, ParseError, QualifiedRule, WhitespaceToken | ||
|
|
||
| _Rule: TypeAlias = QualifiedRule | AtRule | Comment | WhitespaceToken | ParseError | ||
|
|
||
| def parse_one_component_value(input: str | Iterable[Node], skip_comments: bool = ...) -> Node: ... | ||
| def parse_one_declaration(input: str | Iterable[Node], skip_comments: bool = ...) -> Declaration | ParseError: ... | ||
| def parse_blocks_contents( | ||
| input: str | Iterable[Node], skip_comments: bool = ..., skip_whitespace: bool = ... | ||
| ) -> list[Declaration | AtRule | QualifiedRule | Comment | WhitespaceToken | ParseError]: ... | ||
| def parse_declaration_list( | ||
| input: str | Iterable[Node], skip_comments: bool = ..., skip_whitespace: bool = ... | ||
| ) -> list[Declaration | AtRule | Comment | WhitespaceToken | ParseError]: ... | ||
| def parse_one_rule(input: str | Iterable[Node], skip_comments: bool = ...) -> QualifiedRule | AtRule | ParseError: ... | ||
| def parse_rule_list(input: str | Iterable[Node], skip_comments: bool = ..., skip_whitespace: bool = ...) -> list[_Rule]: ... | ||
| def parse_stylesheet(input: str | Iterable[Node], skip_comments: bool = ..., skip_whitespace: bool = ...) -> list[_Rule]: ... | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Defaults are missing here as well. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| from collections.abc import Iterable | ||
|
|
||
| from .ast import Node | ||
|
|
||
| def serialize(nodes: Iterable[Node]) -> str: ... | ||
| def serialize_identifier(value: str) -> str: ... | ||
| def serialize_name(value: str) -> str: ... | ||
| def serialize_string_value(value: str) -> str: ... | ||
| def serialize_url(value: str) -> str: ... | ||
|
|
||
| BAD_PAIRS: set[tuple[str, str]] |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,3 @@ | ||||||
| from .ast import Node | ||||||
|
|
||||||
| def parse_component_value_list(css: str, skip_comments: bool = ...) -> list[Node]: ... | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have just merged a PR that changes field names to use dashes: