Skip to content
Merged
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
4 changes: 4 additions & 0 deletions stubs/Pygments/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ pygments.style.Style.name
pygments.style.Style.aliases
pygments.style.Style.web_style_gallery_exclude

# Class attributes that are set to None in the base class, but are
# always overridden with a non-None value in subclasses.
pygments.formatter.Formatter.name

# Individual lexers and styles submodules are not stubbed at this time.
pygments\.lexers\.(?!get_|find_|load_|guess_).*
pygments\.styles\.(?!get_).*
63 changes: 47 additions & 16 deletions stubs/Pygments/pygments/formatter.pyi
Original file line number Diff line number Diff line change
@@ -1,27 +1,58 @@
import types
from _typeshed import Incomplete
from typing import Any, Generic, TypeVar, overload
from _typeshed import SupportsWrite
from collections.abc import Iterable, Sequence
from typing import Any, ClassVar, Generic, TypeVar, overload

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

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

__all__ = ["Formatter"]

class Formatter(Generic[_T]):
name: Incomplete
aliases: Incomplete
filenames: Incomplete
unicodeoutput: bool
style: Incomplete
full: Incomplete
title: Incomplete
encoding: Incomplete
options: Incomplete
name: ClassVar[str] # Set to None, but always overridden with a non-None value in subclasses.
aliases: ClassVar[Sequence[str]] # Not intended to be mutable
filenames: ClassVar[Sequence[str]] # Not intended to be mutable
unicodeoutput: ClassVar[bool]
style: type[Style]
full: bool
title: str
encoding: str | None
options: dict[str, Any] # arbitrary values used by subclasses
@overload
def __init__(self: Formatter[str], *, encoding: None = None, outencoding: None = None, **options) -> None: ...
def __init__(
self: Formatter[str],
*,
style: type[Style] | str = "default",
full: bool = False,
title: str = "",
encoding: None = None,
outencoding: None = None,
**options: Any, # arbitrary values used by subclasses
) -> None: ...
@overload
def __init__(self: Formatter[bytes], *, encoding: str, outencoding: None = None, **options) -> None: ...
def __init__(
self: Formatter[bytes],
*,
style: type[Style] | str = "default",
full: bool = False,
title: str = "",
encoding: str,
outencoding: None = None,
**options: Any, # arbitrary values used by subclasses
) -> None: ...
@overload
def __init__(self: Formatter[bytes], *, encoding: None = None, outencoding: str, **options) -> None: ...
def __init__(
self: Formatter[bytes],
*,
style: type[Style] | str = "default",
full: bool = False,
title: str = "",
encoding: None = None,
outencoding: str,
**options: Any, # arbitrary values used by subclasses
) -> None: ...
def __class_getitem__(cls, name: Any) -> types.GenericAlias: ...
def get_style_defs(self, arg: str = ""): ...
def format(self, tokensource, outfile): ...
def get_style_defs(self, arg: str = "") -> str: ...
def format(self, tokensource: Iterable[tuple[_TokenType, str]], outfile: SupportsWrite[_T]) -> None: ...
11 changes: 5 additions & 6 deletions stubs/Pygments/pygments/formatters/bbcode.pyi
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
from _typeshed import Incomplete
from _typeshed import SupportsWrite
from collections.abc import Iterable
from typing import TypeVar

from pygments.formatter import Formatter
from pygments.token import _TokenType

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

__all__ = ["BBCodeFormatter"]

class BBCodeFormatter(Formatter[_T]):
name: str
aliases: Incomplete
filenames: Incomplete
styles: Incomplete
def format_unencoded(self, tokensource, outfile) -> None: ...
styles: dict[_TokenType, tuple[str, str]]
def format_unencoded(self, tokensource: Iterable[tuple[_TokenType, str]], outfile: SupportsWrite[str]) -> None: ...
9 changes: 4 additions & 5 deletions stubs/Pygments/pygments/formatters/html.pyi
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
from _typeshed import Incomplete
from _typeshed import Incomplete, SupportsWrite
from collections.abc import Iterable
from typing import TypeVar

from pygments.formatter import Formatter
from pygments.token import _TokenType

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

__all__ = ["HtmlFormatter"]

class HtmlFormatter(Formatter[_T]):
name: str
aliases: Incomplete
filenames: Incomplete
title: Incomplete
nowrap: Incomplete
noclasses: Incomplete
Expand Down Expand Up @@ -41,4 +40,4 @@ class HtmlFormatter(Formatter[_T]):
def get_linenos_style_defs(self): ...
def get_css_prefix(self, arg): ...
def wrap(self, source): ...
def format_unencoded(self, tokensource, outfile) -> None: ...
def format_unencoded(self, tokensource: Iterable[tuple[_TokenType, str]], outfile: SupportsWrite[str]) -> None: ...
33 changes: 10 additions & 23 deletions stubs/Pygments/pygments/formatters/img.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from _typeshed import Incomplete
from typing import TypeVar
from _typeshed import Incomplete, SupportsWrite
from collections.abc import Iterable
from typing_extensions import Never

from pygments.formatter import Formatter

_T = TypeVar("_T", str, bytes)
from pygments.token import _TokenType

__all__ = ["ImageFormatter", "GifImageFormatter", "JpgImageFormatter", "BmpImageFormatter"]

Expand All @@ -22,11 +22,7 @@ class FontManager:
def get_font(self, bold, oblique): ...
def get_style(self, style): ...

class ImageFormatter(Formatter[_T]):
name: str
aliases: Incomplete
filenames: Incomplete
unicodeoutput: bool
class ImageFormatter(Formatter[bytes]):
default_image_format: str
encoding: str
styles: Incomplete
Expand All @@ -49,23 +45,14 @@ class ImageFormatter(Formatter[_T]):
hl_lines: Incomplete
hl_color: Incomplete
drawables: Incomplete
def get_style_defs(self, arg: str = "") -> None: ...
def format(self, tokensource, outfile) -> None: ...
def get_style_defs(self, arg: str = "") -> Never: ...
def format(self, tokensource: Iterable[tuple[_TokenType, str]], outfile: SupportsWrite[bytes]) -> None: ...

class GifImageFormatter(ImageFormatter[_T]):
name: str
aliases: Incomplete
filenames: Incomplete
class GifImageFormatter(ImageFormatter):
default_image_format: str

class JpgImageFormatter(ImageFormatter[_T]):
name: str
aliases: Incomplete
filenames: Incomplete
class JpgImageFormatter(ImageFormatter):
default_image_format: str

class BmpImageFormatter(ImageFormatter[_T]):
name: str
aliases: Incomplete
filenames: Incomplete
class BmpImageFormatter(ImageFormatter):
default_image_format: str
9 changes: 4 additions & 5 deletions stubs/Pygments/pygments/formatters/irc.pyi
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
from _typeshed import Incomplete
from _typeshed import Incomplete, SupportsWrite
from collections.abc import Iterable
from typing import TypeVar

from pygments.formatter import Formatter
from pygments.token import _TokenType

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

__all__ = ["IRCFormatter"]

class IRCFormatter(Formatter[_T]):
name: str
aliases: Incomplete
filenames: Incomplete
darkbg: Incomplete
colorscheme: Incomplete
linenos: Incomplete
def format_unencoded(self, tokensource, outfile) -> None: ...
def format_unencoded(self, tokensource: Iterable[tuple[_TokenType, str]], outfile: SupportsWrite[str]) -> None: ...
9 changes: 4 additions & 5 deletions stubs/Pygments/pygments/formatters/latex.pyi
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
from _typeshed import Incomplete
from _typeshed import Incomplete, SupportsWrite
from collections.abc import Iterable
from typing import TypeVar

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

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

__all__ = ["LatexFormatter"]

class LatexFormatter(Formatter[_T]):
name: str
aliases: Incomplete
filenames: Incomplete
docclass: Incomplete
preamble: Incomplete
linenos: Incomplete
Expand All @@ -27,7 +26,7 @@ class LatexFormatter(Formatter[_T]):
right: Incomplete
envname: Incomplete
def get_style_defs(self, arg: str = ""): ...
def format_unencoded(self, tokensource, outfile) -> None: ...
def format_unencoded(self, tokensource: Iterable[tuple[_TokenType, str]], outfile: SupportsWrite[str]) -> None: ...

class LatexEmbeddedLexer(Lexer):
left: Incomplete
Expand Down
19 changes: 6 additions & 13 deletions stubs/Pygments/pygments/formatters/other.pyi
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
from _typeshed import Incomplete
from _typeshed import Incomplete, SupportsWrite
from collections.abc import Iterable
from typing import TypeVar

from pygments.formatter import Formatter
from pygments.token import _TokenType

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

__all__ = ["NullFormatter", "RawTokenFormatter", "TestcaseFormatter"]

class NullFormatter(Formatter[_T]):
name: str
aliases: Incomplete
filenames: Incomplete
def format(self, tokensource, outfile) -> None: ...
def format(self, tokensource: Iterable[tuple[_TokenType, str]], outfile: SupportsWrite[_T]) -> None: ...

class RawTokenFormatter(Formatter[bytes]):
name: str
aliases: Incomplete
filenames: Incomplete
unicodeoutput: bool
encoding: str
compress: Incomplete
error_color: Incomplete
def format(self, tokensource, outfile) -> None: ...
def format(self, tokensource: Iterable[tuple[_TokenType, str]], outfile: SupportsWrite[bytes]) -> None: ...

class TestcaseFormatter(Formatter[_T]):
name: str
aliases: Incomplete
def format(self, tokensource, outfile) -> None: ...
def format(self, tokensource: Iterable[tuple[_TokenType, str]], outfile: SupportsWrite[_T]) -> None: ...
9 changes: 4 additions & 5 deletions stubs/Pygments/pygments/formatters/pangomarkup.pyi
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
from _typeshed import Incomplete
from _typeshed import Incomplete, SupportsWrite
from collections.abc import Iterable
from typing import TypeVar

from pygments.formatter import Formatter
from pygments.token import _TokenType

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

__all__ = ["PangoMarkupFormatter"]

class PangoMarkupFormatter(Formatter[_T]):
name: str
aliases: Incomplete
filenames: Incomplete
styles: Incomplete
def format_unencoded(self, tokensource, outfile) -> None: ...
def format_unencoded(self, tokensource: Iterable[tuple[_TokenType, str]], outfile: SupportsWrite[str]) -> None: ...
9 changes: 4 additions & 5 deletions stubs/Pygments/pygments/formatters/rtf.pyi
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
from _typeshed import Incomplete
from _typeshed import Incomplete, SupportsWrite
from collections.abc import Iterable
from typing import TypeVar

from pygments.formatter import Formatter
from pygments.token import _TokenType

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

__all__ = ["RtfFormatter"]

class RtfFormatter(Formatter[_T]):
name: str
aliases: Incomplete
filenames: Incomplete
fontface: Incomplete
fontsize: Incomplete
@staticmethod
def hex_to_rtf_color(hex_color: str) -> str: ...
def format_unencoded(self, tokensource, outfile) -> None: ...
def format_unencoded(self, tokensource: Iterable[tuple[_TokenType, str]], outfile: SupportsWrite[str]) -> None: ...
9 changes: 4 additions & 5 deletions stubs/Pygments/pygments/formatters/svg.pyi
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
from _typeshed import Incomplete
from _typeshed import Incomplete, SupportsWrite
from collections.abc import Iterable
from typing import TypeVar

from pygments.formatter import Formatter
from pygments.token import _TokenType

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

__all__ = ["SvgFormatter"]

class SvgFormatter(Formatter[_T]):
name: str
aliases: Incomplete
filenames: Incomplete
nowrap: Incomplete
fontfamily: Incomplete
fontsize: Incomplete
Expand All @@ -22,4 +21,4 @@ class SvgFormatter(Formatter[_T]):
linenostart: Incomplete
linenostep: Incomplete
linenowidth: Incomplete
def format_unencoded(self, tokensource, outfile) -> None: ...
def format_unencoded(self, tokensource: Iterable[tuple[_TokenType, str]], outfile: SupportsWrite[str]) -> None: ...
11 changes: 5 additions & 6 deletions stubs/Pygments/pygments/formatters/terminal.pyi
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
from _typeshed import Incomplete
from _typeshed import Incomplete, SupportsWrite
from collections.abc import Iterable
from typing import TypeVar

from pygments.formatter import Formatter
from pygments.token import _TokenType

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

__all__ = ["TerminalFormatter"]

class TerminalFormatter(Formatter[_T]):
name: str
aliases: Incomplete
filenames: Incomplete
darkbg: Incomplete
colorscheme: Incomplete
linenos: Incomplete
def format(self, tokensource, outfile): ...
def format_unencoded(self, tokensource, outfile) -> None: ...
def format(self, tokensource: Iterable[tuple[_TokenType, str]], outfile: SupportsWrite[_T]) -> None: ...
def format_unencoded(self, tokensource: Iterable[tuple[_TokenType, str]], outfile: SupportsWrite[str]) -> None: ...
Loading