Skip to content

Commit c670fec

Browse files
committed
more fixes
1 parent 431fb36 commit c670fec

File tree

4 files changed

+33
-9
lines changed

4 files changed

+33
-9
lines changed

stubs/Pygments/pygments/formatter.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
from _io import _TextIOBase
22
from collections.abc import Iterator
3+
from types import GenericAlias
34
from typing import Any, Generic, TypeVar, overload
45

56
from pygments.style import Style
67
from pygments.token import _TokenType
78

9+
__all__ = ["Formatter"]
10+
811
_T = TypeVar("_T", str, bytes)
912

1013
class Formatter(Generic[_T]):
@@ -25,3 +28,4 @@ class Formatter(Generic[_T]):
2528
def __init__(self: Formatter[bytes], *, encoding: None = None, outencoding: str, **options: Any) -> None: ...
2629
def get_style_defs(self, arg: str = "") -> str: ...
2730
def format(self, tokensource: Iterator[tuple[_TokenType, str]], outfile: _TextIOBase) -> None: ...
31+
def __class_getitem__(cls, name: Any) -> GenericAlias: ...

stubs/Pygments/pygments/lexer.pyi

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,28 @@ from _typeshed import Incomplete
33
from collections.abc import Callable, Iterable, Iterator, Sequence
44
from re import RegexFlag
55
from typing import Any, ClassVar
6+
from typing_extensions import TypeAlias
67

78
from pygments.filter import Filter
89
from pygments.token import _TokenType
910
from pygments.util import Future
1011

12+
__all__ = [
13+
"Lexer",
14+
"RegexLexer",
15+
"ExtendedRegexLexer",
16+
"DelegatingLexer",
17+
"LexerContext",
18+
"include",
19+
"inherit",
20+
"bygroups",
21+
"using",
22+
"this",
23+
"default",
24+
"words",
25+
"line_re",
26+
]
27+
1128
line_re: re.Pattern[str]
1229

1330
class LexerMeta(type):
@@ -110,17 +127,15 @@ class RegexLexerMeta(LexerMeta):
110127
]: ...
111128
def __call__(cls, *args: Any, **kwds: Any) -> Any: ...
112129

130+
_TokenListSecondItemType: TypeAlias = (
131+
_TokenType
132+
| Iterator[tuple[int, _TokenType, str]]
133+
| Callable[[Lexer, _PseudoMatch, LexerContext], Iterator[tuple[int, _TokenType, str]]]
134+
)
135+
113136
class RegexLexer(Lexer, metaclass=RegexLexerMeta):
114137
flags: ClassVar[RegexFlag]
115-
tokens: ClassVar[
116-
dict[
117-
str,
118-
list[
119-
tuple[str, _TokenType | Iterator[tuple[int, _TokenType, str]]]
120-
| tuple[str, _TokenType | Iterator[tuple[int, _TokenType, str]], str]
121-
],
122-
]
123-
]
138+
tokens: ClassVar[dict[str, list[tuple[str, _TokenListSecondItemType] | tuple[str, _TokenListSecondItemType, str] | include]]]
124139
def get_tokens_unprocessed(self, text: str, stack: Iterable[str] = ("root",)) -> Iterator[tuple[int, _TokenType, str]]: ...
125140

126141
class LexerContext:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
__all__ = ["get_filetype_from_buffer"]
2+
13
def get_filetype_from_buffer(buf: str, max_lines: int = 5) -> str: ...

stubs/Pygments/pygments/sphinxext.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from docutils.nodes import Node
12
from docutils.parsers.rst import Directive
23

34
MODULEDOC: str
@@ -7,6 +8,8 @@ FILTERDOC: str
78

89
class PygmentsDoc(Directive):
910
filenames: set[str]
11+
def run(self) -> list[Node]: ...
12+
def document_lexers_overview(self) -> str: ...
1013
def document_lexers(self) -> str: ...
1114
def document_formatters(self) -> str: ...
1215
def document_filters(self) -> str: ...

0 commit comments

Comments
 (0)