Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions stubs/Pygments/pygments/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ __all__ = ["lex", "format", "highlight"]

def lex(code: str, lexer: Lexer) -> Iterator[tuple[_TokenType, str]]: ...
@overload
def format(tokens, formatter: Formatter[_T], outfile: SupportsWrite[_T]) -> None: ...
def format(tokens: Iterator[tuple[_TokenType, str]], formatter: Formatter[_T], outfile: SupportsWrite[_T]) -> None: ...
@overload
def format(tokens, formatter: Formatter[_T], outfile: None = None) -> _T: ...
def format(tokens: Iterator[tuple[_TokenType, str]], formatter: Formatter[_T], outfile: None = None) -> _T: ...
@overload
def highlight(code, lexer, formatter: Formatter[_T], outfile: SupportsWrite[_T]) -> None: ...
def highlight(code: str, lexer: Lexer, formatter: Formatter[_T], outfile: SupportsWrite[_T]) -> None: ...
@overload
def highlight(code, lexer, formatter: Formatter[_T], outfile: None = None) -> _T: ...
def highlight(code: str, lexer: Lexer, formatter: Formatter[_T], outfile: None = None) -> _T: ...
8 changes: 5 additions & 3 deletions stubs/Pygments/pygments/cmdline.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import argparse
import sys
from collections.abc import Sequence

def main_inner(parser, argns): ...
def main_inner(parser: argparse.ArgumentParser, argns: argparse.Namespace) -> int: ...

class HelpFormatter(argparse.HelpFormatter):
def __init__(self, prog, indent_increment: int = 2, max_help_position: int = 16, width=None) -> None: ...
def __init__(self, prog: str, indent_increment: int = 2, max_help_position: int = 16, width: int | None = None) -> None: ...

def main(args=...): ...
def main(args: Sequence[str] = sys.argv) -> int: ...
14 changes: 6 additions & 8 deletions stubs/Pygments/pygments/console.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from typing import Any

esc: str
codes: Any
dark_colors: Any
light_colors: Any
codes: dict[str, str]
dark_colors: list[str]
light_colors: list[str]

def reset_color(): ...
def colorize(color_key, text): ...
def ansiformat(attr, text): ...
def reset_color() -> str: ...
def colorize(color_key: str, text: str) -> str: ...
def ansiformat(attr: str, text: str) -> str: ...
14 changes: 8 additions & 6 deletions stubs/Pygments/pygments/filter.pyi
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
from collections.abc import Iterable, Iterator
from collections.abc import Callable, Generator, Iterable, Iterator
from typing import Any

from pygments.lexer import Lexer
from pygments.token import _TokenType

def apply_filters(stream, filters, lexer=None): ...
def simplefilter(f): ...
def apply_filters(
stream: Callable[[], Iterator[tuple[_TokenType, str]]], filters: list[Filter], lexer: Lexer | None = None
) -> Generator[tuple[_TokenType, str], None, tuple[_TokenType, str]]: ...
def simplefilter(f: Callable[..., Any]) -> type[FunctionFilter]: ...

class Filter:
options: Any
def __init__(self, **options) -> None: ...
def __init__(self, **options: Any) -> None: ...
def filter(self, lexer: Lexer, stream: Iterable[tuple[_TokenType, str]]) -> Iterator[tuple[_TokenType, str]]: ...

class FunctionFilter(Filter):
function: Any
def __init__(self, **options) -> None: ...
function: Callable[..., Any] | None = None
def __init__(self, **options: Any) -> None: ...
def filter(self, lexer: Lexer, stream: Iterable[tuple[_TokenType, str]]) -> Iterator[tuple[_TokenType, str]]: ...
46 changes: 23 additions & 23 deletions stubs/Pygments/pygments/filters/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
from collections.abc import Generator, Iterable, Iterator
from collections.abc import Callable, Generator, Iterable, Iterator
from typing import Any

from pygments.filter import Filter
from pygments.lexer import Lexer
from pygments.token import _TokenType

def find_filter_class(filtername): ...
def get_filter_by_name(filtername, **options): ...
def find_filter_class(filtername: str) -> type[Filter]: ...
def get_filter_by_name(filtername: str, **options: Any) -> Filter: ...
def get_all_filters() -> Generator[str, None, None]: ...

class CodeTagFilter(Filter):
tag_re: Any
def __init__(self, **options) -> None: ...
def __init__(self, **options: Any) -> None: ...
def filter(self, lexer: Lexer, stream: Iterable[tuple[_TokenType, str]]) -> Iterator[tuple[_TokenType, str]]: ...

class SymbolFilter(Filter):
latex_symbols: Any
isabelle_symbols: Any
lang_map: Any
symbols: Any
def __init__(self, **options) -> None: ...
latex_symbols: dict[str, str]
isabelle_symbols: dict[str, str]
lang_map: dict[str, dict[str, str]]
symbols: dict[str, str]
def __init__(self, **options: Any) -> None: ...
def filter(self, lexer: Lexer, stream: Iterable[tuple[_TokenType, str]]) -> Iterator[tuple[_TokenType, str]]: ...

class KeywordCaseFilter(Filter):
convert: Any
def __init__(self, **options) -> None: ...
convert: Callable[[str], str]
def __init__(self, **options: Any) -> None: ...
def filter(self, lexer: Lexer, stream: Iterable[tuple[_TokenType, str]]) -> Iterator[tuple[_TokenType, str]]: ...

class NameHighlightFilter(Filter):
names: Any
tokentype: Any
def __init__(self, **options) -> None: ...
names: set[str]
tokentype: _TokenType
def __init__(self, **options: Any) -> None: ...
def filter(self, lexer: Lexer, stream: Iterable[tuple[_TokenType, str]]) -> Iterator[tuple[_TokenType, str]]: ...

class ErrorToken(Exception): ...

class RaiseOnErrorTokenFilter(Filter):
exception: Any
def __init__(self, **options) -> None: ...
exception: type[Exception]
def __init__(self, **options: Any) -> None: ...
def filter(self, lexer: Lexer, stream: Iterable[tuple[_TokenType, str]]) -> Iterator[tuple[_TokenType, str]]: ...

class VisibleWhitespaceFilter(Filter):
wstt: Any
def __init__(self, **options) -> None: ...
wstt: bool
def __init__(self, **options: Any) -> None: ...
def filter(self, lexer: Lexer, stream: Iterable[tuple[_TokenType, str]]) -> Iterator[tuple[_TokenType, str]]: ...

class GobbleFilter(Filter):
n: Any
def __init__(self, **options) -> None: ...
def gobble(self, value, left): ...
n: int
def __init__(self, **options: Any) -> None: ...
def gobble(self, value: str, left: int) -> tuple[str, int]: ...
def filter(self, lexer: Lexer, stream: Iterable[tuple[_TokenType, str]]) -> Iterator[tuple[_TokenType, str]]: ...

class TokenMergeFilter(Filter):
def __init__(self, **options) -> None: ...
def __init__(self, **options: Any) -> None: ...
def filter(self, lexer: Lexer, stream: Iterable[tuple[_TokenType, str]]) -> Iterator[tuple[_TokenType, str]]: ...

FILTERS: Any
FILTERS: dict[str, type[Filter]]
35 changes: 22 additions & 13 deletions stubs/Pygments/pygments/formatter.pyi
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
from _io import _TextIOBase
from collections.abc import Iterator
from types import GenericAlias
from typing import Any, Generic, TypeVar, overload

from pygments.style import Style
from pygments.token import _TokenType

__all__ = ["Formatter"]

_T = TypeVar("_T", str, bytes)

class Formatter(Generic[_T]):
name: Any
aliases: Any
filenames: Any
name: str | None = None
aliases: list[str]
filenames: list[str]
unicodeoutput: bool
style: Any
full: Any
title: Any
encoding: Any
options: Any
style: type[Style]
full: bool
title: str
encoding: str
options: dict[str, Any]
@overload
def __init__(self: Formatter[str], *, encoding: None = None, outencoding: None = None, **options) -> None: ...
def __init__(self: Formatter[str], *, encoding: None = None, outencoding: None = None, **options: Any) -> None: ...
@overload
def __init__(self: Formatter[bytes], *, encoding: str, outencoding: None = None, **options) -> None: ...
def __init__(self: Formatter[bytes], *, encoding: str, outencoding: None = None, **options: Any) -> None: ...
@overload
def __init__(self: Formatter[bytes], *, encoding: None = None, outencoding: str, **options) -> None: ...
def get_style_defs(self, arg: str = ""): ...
def format(self, tokensource, outfile): ...
def __init__(self: Formatter[bytes], *, encoding: None = None, outencoding: str, **options: Any) -> None: ...
def get_style_defs(self, arg: str = "") -> str: ...
def format(self, tokensource: Iterator[tuple[_TokenType, str]], outfile: _TextIOBase) -> None: ...
def __class_getitem__(cls, name: Any) -> GenericAlias: ...
7 changes: 4 additions & 3 deletions stubs/Pygments/pygments/formatters/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ from .terminal import TerminalFormatter as TerminalFormatter
from .terminal256 import Terminal256Formatter as Terminal256Formatter, TerminalTrueColorFormatter as TerminalTrueColorFormatter

def get_all_formatters() -> Generator[type[Formatter[Any]], None, None]: ...
def get_formatter_by_name(_alias, **options): ...
def load_formatter_from_file(filename, formattername: str = "CustomFormatter", **options): ...
def get_formatter_for_filename(fn, **options): ...
def find_formatter_class(alias: str) -> type[Formatter[Any]]: ...
def get_formatter_by_name(_alias: str, **options: Any) -> Formatter[Any]: ...
def load_formatter_from_file(filename: str, formattername: str = "CustomFormatter", **options: Any) -> Formatter[Any]: ...
def get_formatter_for_filename(fn: str, **options: Any) -> Formatter[Any]: ...
4 changes: 1 addition & 3 deletions stubs/Pygments/pygments/formatters/_mapping.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
from typing import Any

FORMATTERS: Any
FORMATTERS: dict[str, tuple[str, str, tuple[str, ...], tuple[str, ...], str]]
5 changes: 3 additions & 2 deletions stubs/Pygments/pygments/formatters/img.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, TypeVar
from typing import Any, NoReturn, TypeVar

from pygments.formatter import Formatter

Expand Down Expand Up @@ -46,7 +46,8 @@ class ImageFormatter(Formatter[_T]):
hl_lines: Any
hl_color: Any
drawables: Any
def get_style_defs(self, arg: str = "") -> None: ...
# raises NotImplementedError
def get_style_defs(self, arg: str = "") -> NoReturn: ...
def format(self, tokensource, outfile) -> None: ...

class GifImageFormatter(ImageFormatter[_T]):
Expand Down
Loading