Skip to content

Commit 1ac283f

Browse files
committed
add comments about any kwargs
1 parent ea8e6bb commit 1ac283f

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
lines changed

stubs/Pygments/pygments/filter.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ def apply_filters(
1010
def simplefilter(f: Callable[..., Any]) -> type[FunctionFilter]: ...
1111

1212
class Filter:
13-
options: Any
13+
options: dict[str, Any]
14+
# options are kept as a dict on the instance
1415
def __init__(self, **options: Any) -> None: ...
1516
def filter(self, lexer: Lexer, stream: Iterable[tuple[_TokenType, str]]) -> Iterator[tuple[_TokenType, str]]: ...
1617

1718
class FunctionFilter(Filter):
1819
function: Callable[..., Any] | None = None
20+
# options are forwarded to Filter's constructor
1921
def __init__(self, **options: Any) -> None: ...
2022
def filter(self, lexer: Lexer, stream: Iterable[tuple[_TokenType, str]]) -> Iterator[tuple[_TokenType, str]]: ...

stubs/Pygments/pygments/filters/__init__.pyi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def get_all_filters() -> Generator[str, None, None]: ...
1313

1414
class CodeTagFilter(Filter):
1515
tag_re: Any
16+
# options are forwarded to Filter's constructor
1617
def __init__(self, **options: Any) -> None: ...
1718
def filter(self, lexer: Lexer, stream: Iterable[tuple[_TokenType, str]]) -> Iterator[tuple[_TokenType, str]]: ...
1819

@@ -21,39 +22,46 @@ class SymbolFilter(Filter):
2122
isabelle_symbols: dict[str, str]
2223
lang_map: dict[str, dict[str, str]]
2324
symbols: dict[str, str]
25+
# options are forwarded to Filter's constructor
2426
def __init__(self, **options: Any) -> None: ...
2527
def filter(self, lexer: Lexer, stream: Iterable[tuple[_TokenType, str]]) -> Iterator[tuple[_TokenType, str]]: ...
2628

2729
class KeywordCaseFilter(Filter):
2830
convert: Callable[[str], str]
31+
# options are forwarded to Filter's constructor
2932
def __init__(self, **options: Any) -> None: ...
3033
def filter(self, lexer: Lexer, stream: Iterable[tuple[_TokenType, str]]) -> Iterator[tuple[_TokenType, str]]: ...
3134

3235
class NameHighlightFilter(Filter):
3336
names: set[str]
3437
tokentype: _TokenType
38+
# options are forwarded to Filter's constructor
3539
def __init__(self, **options: Any) -> None: ...
3640
def filter(self, lexer: Lexer, stream: Iterable[tuple[_TokenType, str]]) -> Iterator[tuple[_TokenType, str]]: ...
3741

3842
class ErrorToken(Exception): ...
3943

4044
class RaiseOnErrorTokenFilter(Filter):
4145
exception: type[Exception]
46+
# options are forwarded to Filter's constructor
4247
def __init__(self, **options: Any) -> None: ...
4348
def filter(self, lexer: Lexer, stream: Iterable[tuple[_TokenType, str]]) -> Iterator[tuple[_TokenType, str]]: ...
4449

4550
class VisibleWhitespaceFilter(Filter):
4651
wstt: bool
52+
# options are forwarded to Filter's constructor
4753
def __init__(self, **options: Any) -> None: ...
4854
def filter(self, lexer: Lexer, stream: Iterable[tuple[_TokenType, str]]) -> Iterator[tuple[_TokenType, str]]: ...
4955

5056
class GobbleFilter(Filter):
5157
n: int
58+
# options are forwarded to Filter's constructor
5259
def __init__(self, **options: Any) -> None: ...
5360
def gobble(self, value: str, left: int) -> tuple[str, int]: ...
5461
def filter(self, lexer: Lexer, stream: Iterable[tuple[_TokenType, str]]) -> Iterator[tuple[_TokenType, str]]: ...
5562

5663
class TokenMergeFilter(Filter):
64+
# options are forwarded to Filter's constructor
5765
def __init__(self, **options: Any) -> None: ...
5866
def filter(self, lexer: Lexer, stream: Iterable[tuple[_TokenType, str]]) -> Iterator[tuple[_TokenType, str]]: ...
5967

stubs/Pygments/pygments/formatter.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class Formatter(Generic[_T]):
2424
def __init__(self: Formatter[str], *, encoding: None = None, outencoding: None = None, **options: Any) -> None: ...
2525
@overload
2626
def __init__(self: Formatter[bytes], *, encoding: str, outencoding: None = None, **options: Any) -> None: ...
27+
# options are kept as a dict on the instance, some are used directly in the constructor
2728
@overload
2829
def __init__(self: Formatter[bytes], *, encoding: None = None, outencoding: str, **options: Any) -> None: ...
2930
def get_style_defs(self, arg: str = "") -> str: ...

stubs/Pygments/pygments/formatters/__init__.pyi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ from .terminal256 import Terminal256Formatter as Terminal256Formatter, TerminalT
2121

2222
def get_all_formatters() -> Generator[type[Formatter[Any]], None, None]: ...
2323
def find_formatter_class(alias: str) -> type[Formatter[Any]]: ...
24+
25+
# options are forwarded to the formatter's constructor
2426
def get_formatter_by_name(_alias: str, **options: Any) -> Formatter[Any]: ...
27+
28+
# options are forwarded to the formatter's constructor
2529
def load_formatter_from_file(filename: str, formattername: str = "CustomFormatter", **options: Any) -> Formatter[Any]: ...
30+
31+
# options are forwarded to the formatter's constructor
2632
def get_formatter_for_filename(fn: str, **options: Any) -> Formatter[Any]: ...

stubs/Pygments/pygments/lexer.pyi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ class Lexer(metaclass=LexerMeta):
4747
tabsize: int
4848
encoding: str
4949
filters: list[Filter]
50+
# options are kept as a dict on the instance
5051
def __init__(self, **options: Any) -> None: ...
52+
# options are forwarded to the filter's constructor
5153
def add_filter(self, filter_: str | Filter, **options: Any) -> None: ...
5254
def get_tokens(self, text: str, unfiltered: bool = False) -> Iterator[tuple[_TokenType, str]]: ...
5355
def get_tokens_unprocessed(self, text: str) -> Iterator[tuple[int, _TokenType, str]]: ...
@@ -56,6 +58,7 @@ class DelegatingLexer(Lexer):
5658
root_lexer: Lexer
5759
language_lexer: Lexer
5860
needle: Incomplete
61+
# options are forwarded to the lexer's constructor
5962
def __init__(
6063
self, _root_lexer: type[Lexer], _language_lexer: type[Lexer], _needle: _TokenType = ..., **options: Any
6164
) -> None: ...
@@ -86,6 +89,7 @@ class _This: ...
8689

8790
this: _This
8891

92+
# kwargs are forwarded to the lexer's constructor
8993
def using(
9094
_other: _This | Lexer, **kwargs: Any
9195
) -> Callable[[Lexer, _PseudoMatch, LexerContext], Iterator[tuple[int, _TokenType, str]]]: ...
@@ -125,6 +129,7 @@ class RegexLexerMeta(LexerMeta):
125129
| tuple[str, _TokenType | Iterator[tuple[int, _TokenType, str]], str]
126130
],
127131
]: ...
132+
# kwds are forwarded to `type.__call__`
128133
def __call__(cls, *args: Any, **kwds: Any) -> Any: ...
129134

130135
_TokenListSecondItemType: TypeAlias = (

0 commit comments

Comments
 (0)